@bowlos/reservations 0.31.0 → 0.32.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/data.ts"],"names":[],"mappings":";AAaO,IAAM,kBAAA,GAAqB;AAAA;AAAA,EAEhC,eAAA,EAAiB,iBAAA;AAAA,EACjB,eAAA,EAAiB,iBAAA;AAAA,EACjB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,mBAAA,EAAqB,qBAAA;AAAA,EACrB,aAAA,EAAe,eAAA;AAAA;AAAA,EAEf,iBAAA,EAAmB,mBAAA;AAAA,EACnB,iBAAA,EAAmB,mBAAA;AAAA,EACnB,aAAA,EAAe,eAAA;AAAA,EACf,SAAA,EAAW,WAAA;AAAA,EACX,gBAAA,EAAkB,kBAAA;AAAA,EAClB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,gBAAA,EAAkB,kBAAA;AAAA;AAAA,EAElB,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS;AACX;AAWO,IAAM,cAAA,GAAN,MAAM,eAAA,SAAuB,KAAA,CAAM;AAAA;AAAA,EAE/B,IAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,iBAAA;AAAA,EAET,YACE,IAAA,EACA,OAAA,EACA,MAAA,EACA,OAAA,GAAiC,EAAC,EAClC;AACA,IAAA,KAAA,CAAM,OAAA,EAAS,QAAQ,KAAA,KAAU,MAAA,GAAY,SAAY,EAAE,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAO,CAAA;AACjF,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,M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IACA,EAAE,GAAG,IAAA,EAAM,cAAA,EAAe;AAAA,IAC1B,EAAE,MAAM,IAAA;AAAK,GACf;AACF;AAGO,SAAS,2BAAA,CACd,QACA,QAAA,EAC4B;AAC5B,EAAA,OAAO,MAAA,CAAO,IAAA;AAAA,IACZ,6BAAA;AAAA,IACA,EAAE,QAAA,EAAS;AAAA,IACX,EAAE,MAAM,IAAA;AAAK,GACf;AACF;AAGO,SAAS,iBAAA,CACd,QACA,QAAA,EAC+B;AAC/B,EAAA,OAAO,MAAA,CAAO,KAA2B,mBAAA,EAAqB,EAAE,UAAS,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AAC5F;AAGO,SAAS,eAAA,CACd,QACA,QAAA,EAC0B;AAC1B,EAAA,OAAO,MAAA,CAAO,KAAsB,iBAAA,EAAmB,EAAE,UAAS,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACrF","file":"chunk-P5YWNLEC.js","sourcesContent":["/**\n * Error model for the BowlOS Reservations SDK.\n *\n * Every failed gateway call surfaces as a single `BowlosApiError` carrying a\n * stable `code` (string), the HTTP `status`, and — for rate limits — a\n * `retryAfterSeconds`. The gateway normalizes the backend's two error\n * conventions (thrown ConvexError + `{ ok:false }` envelopes) into one JSON\n * shape; this class is the client-side mirror of that shape, so consumers\n * branch on `error.code`, never on message text.\n */\n\n/** Stable error codes the gateway / backend can return. Open set — treat\n * `code` as a string and match against these for known cases. */\nexport const BOWLOS_ERROR_CODES = {\n // Gateway front door\n API_KEY_MISSING: \"API_KEY_MISSING\",\n API_KEY_INVALID: \"API_KEY_INVALID\",\n ORIGIN_NOT_ALLOWED: \"ORIGIN_NOT_ALLOWED\",\n RATE_LIMITED: \"RATE_LIMITED\",\n // Auth\n INVALID_CREDENTIALS: \"INVALID_CREDENTIALS\",\n SIGNUP_FAILED: \"SIGNUP_FAILED\",\n // Shared backend codes\n VALIDATION_FAILED: \"VALIDATION_FAILED\",\n PERMISSION_DENIED: \"PERMISSION_DENIED\",\n SCOPE_REVOKED: \"SCOPE_REVOKED\",\n NOT_FOUND: \"NOT_FOUND\",\n VERSION_CONFLICT: \"VERSION_CONFLICT\",\n PRICING_SNAPSHOT_STALE: \"PRICING_SNAPSHOT_STALE\",\n PAYMENTS_NOT_CONNECTED: \"PAYMENTS_NOT_CONNECTED\",\n CONNECT_ACCOUNT_RESTRICTED: \"CONNECT_ACCOUNT_RESTRICTED\",\n CHECKOUT_EXPIRED: \"CHECKOUT_EXPIRED\",\n // Client-side\n NETWORK_ERROR: \"NETWORK_ERROR\",\n UNKNOWN: \"ERROR\",\n} as const;\n\nexport type BowlosErrorCode =\n | (typeof BOWLOS_ERROR_CODES)[keyof typeof BOWLOS_ERROR_CODES]\n | (string & {});\n\nexport interface BowlosApiErrorOptions {\n retryAfterSeconds?: number;\n cause?: unknown;\n}\n\nexport class BowlosApiError extends Error {\n /** Stable, machine-readable code. Branch on this, not on `message`. */\n readonly code: BowlosErrorCode;\n /** HTTP status (0 for a network failure before any response). */\n readonly status: number;\n /** Seconds to wait before retrying — present only on `RATE_LIMITED`. */\n readonly retryAfterSeconds?: number;\n\n constructor(\n code: BowlosErrorCode,\n message: string,\n status: number,\n options: BowlosApiErrorOptions = {},\n ) {\n super(message, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = \"BowlosApiError\";\n this.code = code;\n this.status = status;\n this.retryAfterSeconds = options.retryAfterSeconds;\n // Restore prototype chain for instanceof across transpile targets.\n Object.setPrototypeOf(this, BowlosApiError.prototype);\n }\n\n /** Too many requests — caller should back off `retryAfterSeconds`. */\n get isRateLimited(): boolean {\n return this.code === BOWLOS_ERROR_CODES.RATE_LIMITED;\n }\n\n /** Bad/expired login. The session could not be established or has lapsed. */\n get isAuthError(): boolean {\n return (\n this.code === BOWLOS_ERROR_CODES.INVALID_CREDENTIALS ||\n this.code === BOWLOS_ERROR_CODES.PERMISSION_DENIED ||\n this.code === BOWLOS_ERROR_CODES.SCOPE_REVOKED\n );\n }\n\n /** Wrong/missing API key or a disallowed origin — a site-config problem,\n * not something the end customer can fix. */\n get isConfigError(): boolean {\n return (\n this.code === BOWLOS_ERROR_CODES.API_KEY_MISSING ||\n this.code === BOWLOS_ERROR_CODES.API_KEY_INVALID ||\n this.code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED\n );\n }\n}\n","/**\n * BowlosClient — the framework-agnostic core of the Reservations SDK.\n *\n * It is a thin, typed client for the public API gateway (`/api/public/v1/*`):\n * - sends the brand API key (`X-BowlOS-Api-Key`) on every request,\n * - attaches the customer bearer token on authenticated calls,\n * - parses the `{ ok, data | error }` envelope and throws a typed\n * `BowlosApiError` on failure,\n * - owns the customer session: sign-in / sign-up / link / sign-out, plus\n * a transparent refresh-and-retry-once when a session has expired.\n *\n * The React layer (hooks + components) wraps this; nothing here imports React.\n */\n\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport type {\n AuthState,\n BowlosClientConfig,\n Customer,\n FetchLike,\n LinkProfile,\n PingResult,\n TokenStore,\n Tokens,\n} from \"./types\";\n\nclass MemoryTokenStore implements TokenStore {\n private tokens: Tokens | null = null;\n get(): Tokens | null {\n return this.tokens;\n }\n set(tokens: Tokens | null): void {\n this.tokens = tokens;\n }\n}\n\n/** A `TokenStore` backed by `localStorage` for browser apps. No-ops under SSR\n * / environments without `localStorage`. */\nexport function localStorageTokenStore(storageKey = \"bowlos.tokens\"): TokenStore {\n return {\n get(): Tokens | null {\n if (typeof localStorage === \"undefined\") return null;\n const raw = localStorage.getItem(storageKey);\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as Partial<Tokens>;\n return parsed.token && parsed.refreshToken\n ? { token: parsed.token, refreshToken: parsed.refreshToken }\n : null;\n } catch {\n return null;\n }\n },\n set(tokens: Tokens | null): void {\n if (typeof localStorage === \"undefined\") return;\n if (tokens) localStorage.setItem(storageKey, JSON.stringify(tokens));\n else localStorage.removeItem(storageKey);\n },\n };\n}\n\ninterface RawResponse {\n status: number;\n body: unknown;\n retryAfterSeconds?: number;\n}\n\ninterface Envelope {\n ok?: boolean;\n data?: unknown;\n error?: { code?: string; message?: string };\n}\n\n/** Codes that mean \"the API key / origin is wrong\" — refreshing the customer\n * token can't fix these, so never retry them. */\nfunction isConfigErrorCode(code: string): boolean {\n return (\n code === BOWLOS_ERROR_CODES.API_KEY_MISSING ||\n code === BOWLOS_ERROR_CODES.API_KEY_INVALID ||\n code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED ||\n code === BOWLOS_ERROR_CODES.RATE_LIMITED\n );\n}\n\n/** Heuristic for \"the customer session lapsed\" — worth one refresh + retry.\n * An expired bearer surfaces as 401, or as PERMISSION_DENIED/SCOPE_REVOKED\n * from the delegated function. Key/origin errors are excluded above. */\nfunction looksLikeExpiredSession(status: number, code: string): boolean {\n if (isConfigErrorCode(code)) return false;\n return (\n status === 401 ||\n code === BOWLOS_ERROR_CODES.PERMISSION_DENIED ||\n code === BOWLOS_ERROR_CODES.SCOPE_REVOKED\n );\n}\n\nexport class BowlosClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly store: TokenStore;\n private readonly fetchFn: FetchLike;\n\n constructor(config: BowlosClientConfig) {\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl.replace(/\\/+$/, \"\");\n this.store = config.tokenStore ?? new MemoryTokenStore();\n this.fetchFn = config.fetch ?? defaultFetch;\n\n if (!this.apiKey) throw new Error(\"BowlosClient: `apiKey` is required.\");\n if (!this.baseUrl) throw new Error(\"BowlosClient: `baseUrl` is required.\");\n }\n\n /** Is there a stored session right now? (Does not validate it server-side.) */\n isAuthenticated(): boolean {\n return this.store.get() !== null;\n }\n\n /** The current token pair, if any (rarely needed directly). */\n getTokens(): Tokens | null {\n return this.store.get();\n }\n\n /**\n * Health + key-validity probe (`GET /ping`). Resolves with the gateway's\n * service info when the API key is accepted; throws a `BowlosApiError` whose\n * `.code` distinguishes the failure (`NETWORK_ERROR`, `API_KEY_INVALID`,\n * `ORIGIN_NOT_ALLOWED`, `RATE_LIMITED`, …). Cheap enough to call on boot, and\n * the basis for `runDoctor`.\n */\n async ping(): Promise<PingResult> {\n const { status, body, retryAfterSeconds } = await this.request(\n \"ping\",\n {},\n this.store.get()?.token,\n \"GET\",\n );\n const env = (body ?? {}) as Envelope;\n if (env.ok === true) return env.data as PingResult;\n\n const code =\n env.error?.code ??\n (status === 429\n ? BOWLOS_ERROR_CODES.RATE_LIMITED\n : status === 404\n ? BOWLOS_ERROR_CODES.NOT_FOUND\n : BOWLOS_ERROR_CODES.UNKNOWN);\n throw new BowlosApiError(\n code,\n env.error?.message ?? `Health ping failed (HTTP ${status}).`,\n status,\n { retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : undefined },\n );\n }\n\n // ── low-level transport ────────────────────────────────────────────────\n\n private async request(\n name: string,\n args: Record<string, unknown>,\n bearer?: string,\n method: \"GET\" | \"POST\" = \"POST\",\n ): Promise<RawResponse> {\n const headers: Record<string, string> = {\n \"X-BowlOS-Api-Key\": this.apiKey,\n };\n if (method !== \"GET\") headers[\"Content-Type\"] = \"application/json\";\n if (bearer) headers[\"Authorization\"] = `Bearer ${bearer}`;\n\n const init: RequestInit = { method, headers };\n if (method !== \"GET\") init.body = JSON.stringify(args);\n\n let res: Response;\n try {\n res = await this.fetchFn(`${this.baseUrl}/${name}`, init);\n } catch (cause) {\n throw new BowlosApiError(\n BOWLOS_ERROR_CODES.NETWORK_ERROR,\n `Network request to \"${name}\" failed.`,\n 0,\n { cause },\n );\n }\n\n const retryHeader = res.headers.get(\"Retry-After\");\n const retryAfterSeconds = retryHeader ? Number(retryHeader) || undefined : undefined;\n\n let body: unknown = null;\n const text = await res.text();\n if (text) {\n try {\n body = JSON.parse(text);\n } catch {\n // Non-JSON (e.g. the router's plain \"No matching routes found\" 404).\n body = { ok: false, error: { code: BOWLOS_ERROR_CODES.NOT_FOUND, message: text.slice(0, 200) } };\n }\n }\n return { status: res.status, body, retryAfterSeconds };\n }\n\n /**\n * Call a gateway route by name (`POST /api/public/v1/<name>`), returning the\n * unwrapped `data`. Set `{ auth: true }` to attach the bearer token and\n * enable refresh-and-retry on an expired session.\n */\n async call<T = unknown>(\n name: string,\n args: Record<string, unknown> = {},\n opts: { auth?: boolean; method?: \"GET\" | \"POST\" } = {},\n ): Promise<T> {\n return this.callInternal<T>(name, args, opts.auth ?? false, false, opts.method ?? \"POST\");\n }\n\n private async callInternal<T>(\n name: string,\n args: Record<string, unknown>,\n auth: boolean,\n retried: boolean,\n method: \"GET\" | \"POST\",\n ): Promise<T> {\n const bearer = auth ? this.store.get()?.token : undefined;\n const { status, body, retryAfterSeconds } = await this.request(name, args, bearer, method);\n const env = (body ?? {}) as Envelope;\n\n if (env.ok === true) {\n // The data-passthrough routes delegate to functions that return their\n // OWN `{ schema_version, ok, data }` envelope, so the gateway double-wraps\n // them. Detect that inner envelope (uniquely marked by `schema_version`)\n // and unwrap it — surfacing an inner `{ ok:false }` as a thrown error.\n // Auth relays + the raw payment-intent payload have no `schema_version`,\n // so they pass straight through. Forward-compatible if the gateway is ever\n // changed to single-wrap (no inner envelope → nothing to unwrap).\n const data: unknown = env.data;\n if (data !== null && typeof data === \"object\" && \"schema_version\" in data && \"ok\" in data) {\n const inner = data as {\n ok: boolean;\n data?: unknown;\n error?: { code?: string; message?: string };\n };\n if (inner.ok === false) {\n throw new BowlosApiError(\n inner.error?.code ?? BOWLOS_ERROR_CODES.UNKNOWN,\n inner.error?.message ?? `Request to \"${name}\" failed.`,\n status,\n );\n }\n return inner.data as T;\n }\n return data as T;\n }\n\n const code =\n env.error?.code ??\n (status === 429\n ? BOWLOS_ERROR_CODES.RATE_LIMITED\n : status === 404\n ? BOWLOS_ERROR_CODES.NOT_FOUND\n : BOWLOS_ERROR_CODES.UNKNOWN);\n const message = env.error?.message ?? `Request to \"${name}\" failed (HTTP ${status}).`;\n\n if (auth && !retried && this.store.get() && looksLikeExpiredSession(status, code)) {\n const refreshed = await this.tryRefresh();\n if (refreshed) return this.callInternal<T>(name, args, auth, true, method);\n }\n\n throw new BowlosApiError(code, message, status, {\n retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : undefined,\n });\n }\n\n /** Exchange the stored refresh token for a fresh pair. Clears the session if\n * the refresh token is itself invalid/expired. Returns success. */\n private async tryRefresh(): Promise<boolean> {\n const current = this.store.get();\n if (!current?.refreshToken) return false;\n const { status, body } = await this.request(\"auth/refresh\", {\n refreshToken: current.refreshToken,\n });\n const env = (body ?? {}) as Envelope & { data?: { tokens?: Tokens } };\n if (status >= 200 && status < 300 && env.ok === true && env.data?.tokens) {\n this.store.set(env.data.tokens);\n return true;\n }\n this.store.set(null);\n return false;\n }\n\n // ── auth lifecycle ───────────────────────────────────────────────────────\n\n /** Sign an existing customer in; stores the session on success. */\n async signIn(email: string, password: string): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/signin\", { email, password });\n this.store.set(tokens);\n return tokens;\n }\n\n /**\n * Atomic sign-up (preferred): create the login AND the brand-scoped customer\n * profile in ONE server call, then store the session. Use this instead of\n * `signUp()` + `link()` — the two-step path can strand a login with no\n * customer profile if `link()` is missed or races the new session.\n */\n async register(\n email: string,\n password: string,\n profile: Omit<LinkProfile, \"email\">,\n ): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/register\", {\n email,\n password,\n ...profile,\n });\n this.store.set(tokens);\n return tokens;\n }\n\n /** Low-level: create a login only (no customer profile). Prefer `register()`;\n * if you use this you MUST follow with `link()` or the customer is orphaned. */\n async signUp(email: string, password: string): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/signup\", { email, password });\n this.store.set(tokens);\n return tokens;\n }\n\n /**\n * Forgot-password step 1: email a reset code to the address (if it has an\n * account at this center). Resolves regardless of whether the email exists —\n * the server never reveals that, to prevent account enumeration. No session\n * needed.\n */\n async requestPasswordReset(email: string): Promise<void> {\n await this.call(\"auth/request-reset\", { email });\n }\n\n /**\n * Forgot-password step 2: verify the emailed code + set a new password. On\n * success the customer is signed in (the session is stored), so the UI can\n * continue straight into the funnel. Throws `INVALID_RESET` on a bad/expired\n * code and `PASSWORD_TOO_WEAK` if the new password fails the policy.\n */\n async resetPassword(\n email: string,\n code: string,\n newPassword: string,\n ): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/reset\", {\n email,\n code,\n newPassword,\n });\n this.store.set(tokens);\n return tokens;\n }\n\n /** Link the signed-in auth user to a customer profile at the brand. */\n async link(profile: LinkProfile): Promise<unknown> {\n return this.call(\"auth/link\", { ...profile }, { auth: true });\n }\n\n /** End the session (best-effort server call; always clears locally). */\n async signOut(): Promise<void> {\n try {\n await this.call(\"auth/signout\", {}, { auth: true });\n } catch {\n // Even if the server call fails (expired token, network), drop locally.\n } finally {\n this.store.set(null);\n }\n }\n\n /** Session bootstrap: unauthenticated / authed-no-customer / linked.\n * GET — matches the gateway's `GET /auth/probe` route. */\n async probe(): Promise<AuthState> {\n const { state } = await this.call<{ state: AuthState }>(\n \"auth/probe\",\n {},\n { auth: true, method: \"GET\" },\n );\n return state;\n }\n\n /** The signed-in customer's profile, or null.\n * GET — matches the gateway's `GET /auth/me` route. */\n async me(): Promise<Customer | null> {\n const { customer } = await this.call<{ customer: Customer | null }>(\n \"auth/me\",\n {},\n { auth: true, method: \"GET\" },\n );\n return customer;\n }\n}\n\n/** Default transport: the global fetch, invoked on `globalThis` so browsers\n * don't throw \"Illegal invocation\". Fails only on first use if absent. */\nconst defaultFetch: FetchLike = (input, init) => {\n if (typeof globalThis.fetch !== \"function\") {\n throw new BowlosApiError(\n BOWLOS_ERROR_CODES.NETWORK_ERROR,\n \"No global fetch available. Pass `config.fetch`.\",\n 0,\n );\n }\n return globalThis.fetch(input, init);\n};\n\n/** Create a configured client. */\nexport function createBowlosClient(config: BowlosClientConfig): BowlosClient {\n return new BowlosClient(config);\n}\n","/**\n * Typed data surface for @bowlos/reservations — booking-funnel reads.\n *\n * Arg shapes mirror the gateway functions; result shapes type the headline\n * fields and pass the rest through (`[key: string]: unknown`), so the backend's\n * full breakdown can grow without an SDK release. Each read has a\n * framework-agnostic function here and a React hook in `hooks.tsx`, sharing\n * these types.\n *\n * This file is React-free, so it's exported from the core entry. The hooks\n * (React) live in `hooks.tsx` under the React entry.\n */\nimport type { BowlosClient } from \"./client\";\n\n/** Inputs for `checkAvailability`. Times are minutes-of-day in the Center's tz. */\nexport type AvailabilityArgs = {\n productId: string;\n dateISO: string;\n startMinuteOfDay: number;\n endMinuteOfDay: number;\n};\n\nexport interface AvailabilityResult {\n totalUnits: number;\n busyUnitIds: string[];\n}\n\nexport type PricingMode = \"per_unit_per_hour\" | \"per_person_per_hour\" | \"per_game\";\n\nexport type BookingAddonSelection = { addonId: string; quantity: number };\n\n/** A bookable add-on for a product (shoe rental, upgrades…). `rateMode` is how\n * it prices — `per_person` (× bowlers), `per_unit` (× lanes), or `flat` (once).\n * `defaultQuantityRule: \"one_per_guest\"` hints the natural quantity is the\n * party size; `\"manual\"` means the customer picks. */\nexport interface PublicAddon {\n id: string;\n displayId: string;\n name: string;\n description: string | null;\n priceCents: number;\n rateMode: \"per_person\" | \"per_unit\" | \"flat\";\n defaultQuantityRule: \"one_per_guest\" | \"manual\";\n}\n\n/** Inputs for `bookingPreview` (the authoritative price quote). */\nexport type BookingPreviewArgs = {\n centerId: string;\n productId: string;\n dateISO: string;\n startMinuteOfDay: number;\n endMinuteOfDay: number;\n mode: PricingMode;\n units?: number;\n persons?: number;\n games?: number;\n addons?: BookingAddonSelection[];\n shareToken?: string;\n subtypeId?: string;\n /** Reservation-mode event offer slug. Binds preview to that offer's event\n * price plan, tax override, and Center fee override/inheritance. */\n eventOfferSlug?: string;\n};\n\n/** The price quote. Headline fields are typed; the engine's full breakdown\n * (line items, discounts, tax, credit) is passed through. */\nexport interface BookingQuote {\n reservationFee: Record<string, unknown> | null;\n totalCentsPerPlan: Array<{ pricePlanId: string; totalCents: number }>;\n taxLinesPerPlan?: Array<{\n pricePlanId: string;\n taxLines: Array<{\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }>;\n taxTotalCents: number;\n }>;\n [key: string]: unknown;\n}\n\n/** Free units for a product/date/time window (anonymous). */\nexport function checkAvailability(\n client: BowlosClient,\n args: AvailabilityArgs,\n): Promise<AvailabilityResult> {\n return client.call<AvailabilityResult>(\"checkAvailability\", args);\n}\n\n/** Authoritative price quote for the chosen inputs. Anonymous by default\n * (the center's standard online price). Pass `{ auth: true }` when the\n * customer has a session so the quote includes member rate + account\n * credit — headless sites must opt in, since the core doesn't track\n * session state. (The `<BookingFlow>` reference + `useBookingPreview`\n * hook do this automatically off `useAccount`.) */\nexport function bookingPreview(\n client: BowlosClient,\n args: BookingPreviewArgs,\n opts?: { auth?: boolean },\n): Promise<BookingQuote> {\n return client.call<BookingQuote>(\"bookingPreview\", args, {\n auth: opts?.auth ?? false,\n });\n}\n\n/** Add-ons available for a product (shoe rental, upgrades…). Anonymous-callable;\n * feed the customer's picks back as `addons` on the preview + the booking. */\nexport function listAddons(\n client: BowlosClient,\n args: { productId: string },\n): Promise<PublicAddon[]> {\n return client.call<PublicAddon[]>(\"listPublicAddons\", args);\n}\n\n/** Inputs for `availableStartTimes`. */\nexport type StartTimesArgs = {\n productId: string;\n dateISO: string;\n /** Booking length, to leave room before close. Default 60 on the server. */\n durationMinutes?: number;\n /** Grid step in minutes. Default 30 on the server. */\n stepMinutes?: number;\n mode?: PricingMode;\n};\n\n/** The bookable start times (minute-of-day, ascending) for a product on a date:\n * within operating hours, past the booking buffer, and backed by a real price\n * plan (same pricing engine the quote uses). Anonymous-callable. */\nexport function listStartTimes(\n client: BowlosClient,\n args: StartTimesArgs,\n): Promise<number[]> {\n return client.call<number[]>(\"availableStartTimes\", args);\n}\n\n/** Convenience: free units = total minus the busy set (never negative). */\nexport function availableUnitCount(availability: AvailabilityResult): number {\n return Math.max(0, availability.totalUnits - availability.busyUnitIds.length);\n}\n\n// ── booking flow (hold → pay → confirm) ──────────────────────────────────────\n\n/** Customer identity for a booking (collected in the booking form; the server\n * links/creates the customer per the booking-flow-only signup rule). */\nexport type BookingCustomer = {\n fullName: string;\n email: string;\n mobile?: string;\n marketingOptIn: boolean;\n};\n\n/** Inputs for `createAnonymousBooking` — places the inventory hold. */\nexport type CreateBookingArgs = {\n centerId: string;\n productId: string;\n dateISO: string;\n startMinuteOfDay: number;\n endMinuteOfDay: number;\n mode: PricingMode;\n units?: number;\n persons?: number;\n games?: number;\n addons?: BookingAddonSelection[];\n customer: BookingCustomer;\n /** Apply account credit (requires a signed-in customer). */\n applyCredit?: boolean;\n /** Idempotency key for the create. The SDK generates one if omitted. */\n idempotencyKey?: string;\n shareToken?: string;\n subtypeId?: string;\n /** Reservation-mode event offer slug. Must match the preview slug. */\n eventOfferSlug?: string;\n};\n\n/** Result of placing a booking. The hold→pay path returns `checkoutRefToken`\n * with `requiresPayment: true`; a credit-covered / $0 booking returns the\n * materialized `reservationId` + `reservationDisplayId` with\n * `requiresPayment: false`. Headline fields typed; the rest passes through. */\nexport interface BookingHold {\n checkoutRefToken?: string;\n reservationId?: string | null;\n reservationDisplayId?: string | null;\n requiresPayment: boolean;\n finalCents: number;\n appliedCreditCents: number;\n paidCents?: number;\n holdExpiresAt?: number;\n replayed?: boolean;\n [key: string]: unknown;\n}\n\nexport type CheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid_materialized\"\n | \"expired\"\n | \"payment_failed_retryable\"\n | \"abandoned\";\n\nexport interface CheckoutStatusResult {\n status: CheckoutStatus;\n reservationDisplayId: string | null;\n reservationId: string | null;\n}\n\n/** Stripe (Connect) PaymentIntent data for the UI layer to render Elements.\n * The SDK does NOT load Stripe.js — initialize it with `connectedAccountId`\n * (the operator's connected account) + `clientSecret`. */\nexport interface PaymentIntentInfo {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n customerId: string;\n ephemeralKey: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** The minimal shape `<BowlosPaymentForm>` needs to confirm a payment on the\n * operator's connected account. `PaymentIntentInfo` (booking) and the buy-flow\n * intents both satisfy it; a recurring membership passes the subscription's\n * first-invoice `clientSecret` here too. */\nexport interface ConnectedPaymentInput {\n clientSecret: string;\n connectedAccountId: string;\n customerSessionClientSecret?: string;\n /** Full Test Mode (2026-06-23): the PI's Stripe environment. `<BowlosPaymentForm>`\n * loads the matching publishable key (test vs live) when `testPublishableKey`\n * is supplied. Absent → \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n// ── headless purchases (game passes; packages + memberships follow) ──────────\n\n/** Inputs for a game-pass purchase. The SDK generates an idempotency key if omitted. */\nexport type GameCardPurchaseArgs = {\n templateId: string;\n idempotencyKey?: string;\n shareToken?: string;\n};\n\n/** The connected-account PaymentIntent for a game-pass purchase. Confirm it with\n * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.\n * Poll `getGameCardStatus(refToken)` for materialization. */\nexport interface GameCardPurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n refToken: string | null;\n cardId: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Buy a game pass — mints the connected-account PaymentIntent (requires a\n * signed-in customer; the charge lands on the operator's connected account). */\nexport function createGameCardOrder(\n client: BowlosClient,\n args: GameCardPurchaseArgs,\n): Promise<GameCardPurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<GameCardPurchaseIntent>(\n \"createGameCardPaymentIntent\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\nexport type GameCardCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid_materialized\"\n | \"expired\"\n | \"payment_failed_retryable\"\n | \"abandoned\";\n\nexport interface GameCardStatusResult {\n status: GameCardCheckoutStatus;\n gameCardId: string | null;\n}\n\n/** Poll a game-pass purchase to materialization (by the create's `refToken`). */\nexport function getGameCardStatus(\n client: BowlosClient,\n refToken: string,\n): Promise<GameCardStatusResult> {\n return client.call<GameCardStatusResult>(\n \"getGameCardCheckoutStatus\",\n { refToken },\n { auth: true },\n );\n}\n\n/** Inputs for an itemized game-pass quote. A pass has no config (no date/qty),\n * so it's just the template (+ an optional share token for a private pass).\n * The selling Center is resolved server-side from the customer's home Center. */\nexport type GameCardPreviewArgs = {\n templateId: string;\n shareToken?: string;\n};\n\n/** Server-computed itemized quote for a game-pass purchase — the base price,\n * tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless \"Review\" step. Computed by the SAME engine as the\n * PaymentIntent, so it never diverges from what the customer is charged. */\nexport interface GameCardPreviewResult {\n subtotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a game-pass purchase WITHOUT creating a PaymentIntent —\n * feeds the Review step. Requires a signed-in customer (so tax exemptions +\n * the resolved home Center match the eventual charge). */\nexport function previewGameCard(\n client: BowlosClient,\n args: GameCardPreviewArgs,\n): Promise<GameCardPreviewResult> {\n return client.call<GameCardPreviewResult>(\n \"previewGameCardOrder\",\n args,\n { auth: true },\n );\n}\n\nexport type EventTicketPreviewArgs = {\n eventOfferId: string;\n quantity: number;\n};\n\nexport interface EventTicketPreviewResult {\n eventName: string;\n eventDate: string;\n quantity: number;\n unitPriceCents: number;\n subtotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a ticket-mode event offer WITHOUT creating a\n * PaymentIntent. Requires a signed-in customer so tax exemptions match the\n * eventual charge. */\nexport function previewEventTicket(\n client: BowlosClient,\n args: EventTicketPreviewArgs,\n): Promise<EventTicketPreviewResult> {\n return client.call<EventTicketPreviewResult>(\n \"previewEventTicketOrder\",\n args,\n { auth: true },\n );\n}\n\nexport type EventTicketPurchaseArgs = {\n eventOfferId: string;\n quantity: number;\n idempotencyKey?: string;\n};\n\n/** The connected-account PaymentIntent for a ticket-mode event purchase.\n * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` +\n * the customer session. After payment, read the receipt with `getMyEventOrder`. */\nexport interface EventTicketPurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n orderId: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Buy tickets for a ticket-mode event offer — mints the connected-account\n * PaymentIntent. Requires a signed-in customer so taxes and account ownership\n * match the preview. */\nexport function createEventTicketOrder(\n client: BowlosClient,\n args: EventTicketPurchaseArgs,\n): Promise<EventTicketPurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<EventTicketPurchaseIntent>(\n \"createEventTicketPaymentIntent\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\nexport type EventTicketCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid\"\n | \"cancelled\"\n | \"refunded\";\n\nexport interface EventTicketStatusResult {\n status: EventTicketCheckoutStatus;\n orderId: string | null;\n}\n\n/** Poll a ticket-mode event purchase by the order id returned from create. */\nexport function getEventTicketStatus(\n client: BowlosClient,\n orderId: string,\n): Promise<EventTicketStatusResult> {\n return client.call<EventTicketStatusResult>(\n \"getEventTicketCheckoutStatus\",\n { orderId },\n { auth: true },\n );\n}\n\n// ── headless purchases: packages ─────────────────────────────────────────────\n\n/** Inputs for a package purchase. The SDK generates an idempotency key if omitted.\n * `scheduledDate` is `YYYY-MM-DD` in the Center's timezone; `scheduledStartMinute`\n * is minutes-from-midnight (e.g. 1050 = 5:30 PM) and MUST be one of the package's\n * bookable start times — see HEADLESS.md → \"Buying a package\" for computing them. */\nexport type PackagePurchaseArgs = {\n packageId: string;\n centerId: string;\n quantity: number;\n optionalAddons?: { addonId: string; quantity: number }[];\n scheduledDate: string;\n scheduledStartMinute: number;\n idempotencyKey?: string;\n shareToken?: string;\n};\n\n/** The connected-account PaymentIntent for a package purchase. Confirm it with\n * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.\n * Poll `getPackageStatus(orderId)` for materialization. */\nexport interface PackagePurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n orderId: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Group id for the inventory hold the order created — subscribe with\n * `getMyHoldGroup` to render the checkout countdown if you choose to. */\n inventoryHoldGroupId?: string;\n}\n\n/** Buy a package — mints the connected-account PaymentIntent (requires a\n * signed-in customer; the charge lands on the operator's connected account). */\nexport function createPackageOrder(\n client: BowlosClient,\n args: PackagePurchaseArgs,\n): Promise<PackagePurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<PackagePurchaseIntent>(\n \"createPackagePaymentIntent\",\n { ...args, optionalAddons: args.optionalAddons ?? [], idempotencyKey },\n { auth: true },\n );\n}\n\nexport type PackageCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid\"\n | \"cancelled\"\n | \"refunded\";\n\nexport interface PackageStatusResult {\n status: PackageCheckoutStatus;\n orderId: string | null;\n}\n\n/** Poll a package purchase to materialization (by the create's `orderId`). */\nexport function getPackageStatus(\n client: BowlosClient,\n orderId: string,\n): Promise<PackageStatusResult> {\n return client.call<PackageStatusResult>(\n \"getPackageCheckoutStatus\",\n { orderId },\n { auth: true },\n );\n}\n\n/** Inputs for an itemized package quote — the buy config minus the schedule\n * (price doesn't depend on date/time; the schedule only affects the eventual\n * create's slot validation). */\nexport type PackagePreviewArgs = {\n packageId: string;\n centerId: string;\n quantity: number;\n optionalAddons?: { addonId: string; quantity: number }[];\n shareToken?: string;\n};\n\n/** Server-computed itemized quote for a package order — base, optional add-ons,\n * tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless \"Review\" step. Computed by the SAME engine as the\n * PaymentIntent, so it never diverges from what the customer is charged. */\nexport interface PackagePreviewResult {\n baseTotalCents: number;\n addons: { addonId: string; name: string; quantity: number; lineCents: number }[];\n addonsTotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a package order WITHOUT creating a PaymentIntent — feeds\n * the Review step. Requires a signed-in customer (so tax exemptions match the\n * eventual charge). */\nexport function previewPackage(\n client: BowlosClient,\n args: PackagePreviewArgs,\n): Promise<PackagePreviewResult> {\n return client.call<PackagePreviewResult>(\n \"previewPackageOrder\",\n { ...args, optionalAddons: args.optionalAddons ?? [] },\n { auth: true },\n );\n}\n\n// ── headless purchases: memberships (one-time + recurring) ───────────────────\n\n/** Inputs for an itemized membership quote. A membership has no config (no\n * date/qty), so it's just the template (+ an optional share token for a private\n * membership). The selling Center is resolved server-side from the customer's\n * home Center. Shared by the one-time and recurring previews. */\nexport type MembershipPreviewArgs = {\n templateId: string;\n shareToken?: string;\n};\n\n/** Server-computed itemized quote for a one-time membership purchase — the dues,\n * the one-time setup (joining) fee, tax lines, the selling Center's booking fee,\n * and the authoritative grand total. Drives the headless \"Review\" step. Computed\n * by the SAME engine as the PaymentIntent, so it never diverges from what the\n * customer is charged. */\nexport interface MembershipPreviewResult {\n duesCents: number;\n setupFeeCents: number;\n subtotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a one-time membership purchase WITHOUT creating a\n * PaymentIntent — feeds the Review step. Requires a signed-in customer (so tax\n * exemptions + the resolved home Center match the eventual charge). */\nexport function previewMembership(\n client: BowlosClient,\n args: MembershipPreviewArgs,\n): Promise<MembershipPreviewResult> {\n return client.call<MembershipPreviewResult>(\n \"previewMembershipOrder\",\n args,\n { auth: true },\n );\n}\n\n/** Inputs for a one-time membership purchase. The SDK generates an idempotency\n * key if omitted. */\nexport type MembershipPurchaseArgs = {\n templateId: string;\n idempotencyKey?: string;\n shareToken?: string;\n};\n\n/** The connected-account PaymentIntent for a one-time membership purchase.\n * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` + the\n * customer session. Poll `getMembershipStatus(refToken)` for materialization. */\nexport interface MembershipPurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n refToken: string | null;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Buy a one-time membership — mints the connected-account PaymentIntent\n * (requires a signed-in customer; the charge lands on the operator's connected\n * account). */\nexport function createMembershipOrder(\n client: BowlosClient,\n args: MembershipPurchaseArgs,\n): Promise<MembershipPurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<MembershipPurchaseIntent>(\n \"createMembershipPaymentIntent\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\nexport type MembershipCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid_materialized\"\n | \"expired\"\n | \"payment_failed_retryable\"\n | \"abandoned\";\n\nexport interface MembershipStatusResult {\n status: MembershipCheckoutStatus;\n membershipId: string | null;\n}\n\n/** Poll a one-time membership purchase to materialization (by the create's\n * `refToken`). */\nexport function getMembershipStatus(\n client: BowlosClient,\n refToken: string,\n): Promise<MembershipStatusResult> {\n return client.call<MembershipStatusResult>(\n \"getMembershipCheckoutStatus\",\n { refToken },\n { auth: true },\n );\n}\n\n/** Server-computed itemized quote for a RECURRING membership subscription — the\n * same fields as the one-time quote (what's charged today: dues + one-time setup\n * fee + tax + the selling Center's fee), PLUS `recurringTotalCents` (what each\n * renewal charges) and the `cadence`. Drives the recurring \"Review\" step's\n * \"Due today\" + \"Auto-renews at\" lines. Computed by the SAME engine as the\n * subscription's first invoice, so it never diverges. */\nexport interface MembershipSubscriptionPreviewResult extends MembershipPreviewResult {\n recurringTotalCents: number;\n cadence: \"monthly\" | \"annual\" | \"one_time\";\n}\n\n/** Itemized quote for a recurring membership subscription WITHOUT creating the\n * subscription — feeds the Review step. Requires a signed-in customer (so tax\n * exemptions + the resolved home Center match the eventual charge). */\nexport function previewMembershipSubscription(\n client: BowlosClient,\n args: MembershipPreviewArgs,\n): Promise<MembershipSubscriptionPreviewResult> {\n return client.call<MembershipSubscriptionPreviewResult>(\n \"previewMembershipSubscriptionOrder\",\n args,\n { auth: true },\n );\n}\n\n/** Inputs for a recurring membership subscription. (No idempotency key — the\n * subscription itself is the dedupe anchor; the buy is gated to one active\n * membership per customer.) */\nexport type MembershipSubscriptionArgs = {\n templateId: string;\n shareToken?: string;\n};\n\n/** The connected-account first-invoice payment for a recurring membership\n * subscription. Confirm `clientSecret` with `<BowlosPaymentForm>` — it carries\n * `connectedAccountId` + the customer session. There is NO refToken: the\n * subscription materializes via webhook, so re-query `useMyMemberships` after\n * payment rather than polling. */\nexport interface MembershipSubscriptionIntent {\n subscriptionId: string;\n clientSecret: string;\n amountCents: number;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Start a recurring membership subscription — mints the subscription + its\n * first-invoice PaymentIntent on the operator's connected account (requires a\n * signed-in customer). Confirm the returned `clientSecret`; the subscription\n * materializes via webhook. */\nexport function createMembershipSubscriptionOrder(\n client: BowlosClient,\n args: MembershipSubscriptionArgs,\n): Promise<MembershipSubscriptionIntent> {\n return client.call<MembershipSubscriptionIntent>(\n \"createMembershipSubscription\",\n args,\n { auth: true },\n );\n}\n\n/** Browser/Node-safe idempotency key for booking creates. */\nexport function generateIdempotencyKey(): string {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n return `idem_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;\n}\n\n/** Place the inventory hold + open a checkout. Sends the session when present\n * (member rates + account credit); falls back to anonymous. */\nexport function createBooking(\n client: BowlosClient,\n args: CreateBookingArgs,\n): Promise<BookingHold> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<BookingHold>(\n \"createAnonymousBooking\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\n/** Mint the Stripe Connect PaymentIntent for a held checkout (by refToken). */\nexport function createCheckoutPaymentIntent(\n client: BowlosClient,\n refToken: string,\n): Promise<PaymentIntentInfo> {\n return client.call<PaymentIntentInfo>(\n \"createCheckoutPaymentIntent\",\n { refToken },\n { auth: true },\n );\n}\n\n/** Poll the hold→pay→materialize state for a checkout (by refToken). */\nexport function getCheckoutStatus(\n client: BowlosClient,\n refToken: string,\n): Promise<CheckoutStatusResult> {\n return client.call<CheckoutStatusResult>(\"getCheckoutStatus\", { refToken }, { auth: true });\n}\n\n/** Release the hold + cancel the checkout (the \"Back\" button). */\nexport function abandonCheckout(\n client: BowlosClient,\n refToken: string,\n): Promise<{ ok: boolean }> {\n return client.call<{ ok: boolean }>(\"abandonCheckout\", { refToken }, { auth: true });\n}\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/data.ts"],"names":[],"mappings":";AAaO,IAAM,kBAAA,GAAqB;AAAA;AAAA,EAEhC,eAAA,EAAiB,iBAAA;AAAA,EACjB,eAAA,EAAiB,iBAAA;AAAA,EACjB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,YAAA,EAAc,cAAA;AAAA;AAAA,EAEd,mBAAA,EAAqB,qBAAA;AAAA,EACrB,aAAA,EAAe,eAAA;AAAA;AAAA,EAEf,iBAAA,EAAmB,mBAAA;AAAA,EACnB,iBAAA,EAAmB,mBAAA;AAAA,EACnB,aAAA,EAAe,eAAA;AAAA,EACf,SAAA,EAAW,WAAA;AAAA,EACX,gBAAA,EAAkB,kBAAA;AAAA,EAClB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,s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*\n * Every failed gateway call surfaces as a single `BowlosApiError` carrying a\n * stable `code` (string), the HTTP `status`, and — for rate limits — a\n * `retryAfterSeconds`. The gateway normalizes the backend's two error\n * conventions (thrown ConvexError + `{ ok:false }` envelopes) into one JSON\n * shape; this class is the client-side mirror of that shape, so consumers\n * branch on `error.code`, never on message text.\n */\n\n/** Stable error codes the gateway / backend can return. Open set — treat\n * `code` as a string and match against these for known cases. */\nexport const BOWLOS_ERROR_CODES = {\n // Gateway front door\n API_KEY_MISSING: \"API_KEY_MISSING\",\n API_KEY_INVALID: \"API_KEY_INVALID\",\n ORIGIN_NOT_ALLOWED: \"ORIGIN_NOT_ALLOWED\",\n RATE_LIMITED: \"RATE_LIMITED\",\n // Auth\n INVALID_CREDENTIALS: \"INVALID_CREDENTIALS\",\n SIGNUP_FAILED: \"SIGNUP_FAILED\",\n // Shared backend codes\n VALIDATION_FAILED: \"VALIDATION_FAILED\",\n PERMISSION_DENIED: \"PERMISSION_DENIED\",\n SCOPE_REVOKED: \"SCOPE_REVOKED\",\n NOT_FOUND: \"NOT_FOUND\",\n VERSION_CONFLICT: \"VERSION_CONFLICT\",\n PRICING_SNAPSHOT_STALE: \"PRICING_SNAPSHOT_STALE\",\n PAYMENTS_NOT_CONNECTED: \"PAYMENTS_NOT_CONNECTED\",\n CONNECT_ACCOUNT_RESTRICTED: \"CONNECT_ACCOUNT_RESTRICTED\",\n CHECKOUT_EXPIRED: \"CHECKOUT_EXPIRED\",\n // Client-side\n NETWORK_ERROR: \"NETWORK_ERROR\",\n UNKNOWN: \"ERROR\",\n} as const;\n\nexport type BowlosErrorCode =\n | (typeof BOWLOS_ERROR_CODES)[keyof typeof BOWLOS_ERROR_CODES]\n | (string & {});\n\nexport interface BowlosApiErrorOptions {\n retryAfterSeconds?: number;\n cause?: unknown;\n}\n\nexport class BowlosApiError extends Error {\n /** Stable, machine-readable code. Branch on this, not on `message`. */\n readonly code: BowlosErrorCode;\n /** HTTP status (0 for a network failure before any response). */\n readonly status: number;\n /** Seconds to wait before retrying — present only on `RATE_LIMITED`. */\n readonly retryAfterSeconds?: number;\n\n constructor(\n code: BowlosErrorCode,\n message: string,\n status: number,\n options: BowlosApiErrorOptions = {},\n ) {\n super(message, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = \"BowlosApiError\";\n this.code = code;\n this.status = status;\n this.retryAfterSeconds = options.retryAfterSeconds;\n // Restore prototype chain for instanceof across transpile targets.\n Object.setPrototypeOf(this, BowlosApiError.prototype);\n }\n\n /** Too many requests — caller should back off `retryAfterSeconds`. */\n get isRateLimited(): boolean {\n return this.code === BOWLOS_ERROR_CODES.RATE_LIMITED;\n }\n\n /** Bad/expired login. The session could not be established or has lapsed. */\n get isAuthError(): boolean {\n return (\n this.code === BOWLOS_ERROR_CODES.INVALID_CREDENTIALS ||\n this.code === BOWLOS_ERROR_CODES.PERMISSION_DENIED ||\n this.code === BOWLOS_ERROR_CODES.SCOPE_REVOKED\n );\n }\n\n /** Wrong/missing API key or a disallowed origin — a site-config problem,\n * not something the end customer can fix. */\n get isConfigError(): boolean {\n return (\n this.code === BOWLOS_ERROR_CODES.API_KEY_MISSING ||\n this.code === BOWLOS_ERROR_CODES.API_KEY_INVALID ||\n this.code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED\n );\n }\n}\n","/**\n * BowlosClient — the framework-agnostic core of the Reservations SDK.\n *\n * It is a thin, typed client for the public API gateway (`/api/public/v1/*`):\n * - sends the brand API key (`X-BowlOS-Api-Key`) on every request,\n * - attaches the customer bearer token on authenticated calls,\n * - parses the `{ ok, data | error }` envelope and throws a typed\n * `BowlosApiError` on failure,\n * - owns the customer session: sign-in / sign-up / link / sign-out, plus\n * a transparent refresh-and-retry-once when a session has expired.\n *\n * The React layer (hooks + components) wraps this; nothing here imports React.\n */\n\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport type {\n AuthState,\n BowlosClientConfig,\n Customer,\n FetchLike,\n LinkProfile,\n PingResult,\n TokenStore,\n Tokens,\n} from \"./types\";\n\nclass MemoryTokenStore implements TokenStore {\n private tokens: Tokens | null = null;\n get(): Tokens | null {\n return this.tokens;\n }\n set(tokens: Tokens | null): void {\n this.tokens = tokens;\n }\n}\n\n/** A `TokenStore` backed by `localStorage` for browser apps. No-ops under SSR\n * / environments without `localStorage`. */\nexport function localStorageTokenStore(storageKey = \"bowlos.tokens\"): TokenStore {\n return {\n get(): Tokens | null {\n if (typeof localStorage === \"undefined\") return null;\n const raw = localStorage.getItem(storageKey);\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as Partial<Tokens>;\n return parsed.token && parsed.refreshToken\n ? { token: parsed.token, refreshToken: parsed.refreshToken }\n : null;\n } catch {\n return null;\n }\n },\n set(tokens: Tokens | null): void {\n if (typeof localStorage === \"undefined\") return;\n if (tokens) localStorage.setItem(storageKey, JSON.stringify(tokens));\n else localStorage.removeItem(storageKey);\n },\n };\n}\n\ninterface RawResponse {\n status: number;\n body: unknown;\n retryAfterSeconds?: number;\n}\n\ninterface Envelope {\n ok?: boolean;\n data?: unknown;\n error?: { code?: string; message?: string };\n}\n\n/** Codes that mean \"the API key / origin is wrong\" — refreshing the customer\n * token can't fix these, so never retry them. */\nfunction isConfigErrorCode(code: string): boolean {\n return (\n code === BOWLOS_ERROR_CODES.API_KEY_MISSING ||\n code === BOWLOS_ERROR_CODES.API_KEY_INVALID ||\n code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED ||\n code === BOWLOS_ERROR_CODES.RATE_LIMITED\n );\n}\n\n/** Heuristic for \"the customer session lapsed\" — worth one refresh + retry.\n * An expired bearer surfaces as 401, or as PERMISSION_DENIED/SCOPE_REVOKED\n * from the delegated function. Key/origin errors are excluded above. */\nfunction looksLikeExpiredSession(status: number, code: string): boolean {\n if (isConfigErrorCode(code)) return false;\n return (\n status === 401 ||\n code === BOWLOS_ERROR_CODES.PERMISSION_DENIED ||\n code === BOWLOS_ERROR_CODES.SCOPE_REVOKED\n );\n}\n\nexport class BowlosClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly store: TokenStore;\n private readonly fetchFn: FetchLike;\n\n constructor(config: BowlosClientConfig) {\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl.replace(/\\/+$/, \"\");\n this.store = config.tokenStore ?? new MemoryTokenStore();\n this.fetchFn = config.fetch ?? defaultFetch;\n\n if (!this.apiKey) throw new Error(\"BowlosClient: `apiKey` is required.\");\n if (!this.baseUrl) throw new Error(\"BowlosClient: `baseUrl` is required.\");\n }\n\n /** Is there a stored session right now? (Does not validate it server-side.) */\n isAuthenticated(): boolean {\n return this.store.get() !== null;\n }\n\n /** The current token pair, if any (rarely needed directly). */\n getTokens(): Tokens | null {\n return this.store.get();\n }\n\n /**\n * Health + key-validity probe (`GET /ping`). Resolves with the gateway's\n * service info when the API key is accepted; throws a `BowlosApiError` whose\n * `.code` distinguishes the failure (`NETWORK_ERROR`, `API_KEY_INVALID`,\n * `ORIGIN_NOT_ALLOWED`, `RATE_LIMITED`, …). Cheap enough to call on boot, and\n * the basis for `runDoctor`.\n */\n async ping(): Promise<PingResult> {\n const { status, body, retryAfterSeconds } = await this.request(\n \"ping\",\n {},\n this.store.get()?.token,\n \"GET\",\n );\n const env = (body ?? {}) as Envelope;\n if (env.ok === true) return env.data as PingResult;\n\n const code =\n env.error?.code ??\n (status === 429\n ? BOWLOS_ERROR_CODES.RATE_LIMITED\n : status === 404\n ? BOWLOS_ERROR_CODES.NOT_FOUND\n : BOWLOS_ERROR_CODES.UNKNOWN);\n throw new BowlosApiError(\n code,\n env.error?.message ?? `Health ping failed (HTTP ${status}).`,\n status,\n { retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : undefined },\n );\n }\n\n // ── low-level transport ────────────────────────────────────────────────\n\n private async request(\n name: string,\n args: Record<string, unknown>,\n bearer?: string,\n method: \"GET\" | \"POST\" = \"POST\",\n ): Promise<RawResponse> {\n const headers: Record<string, string> = {\n \"X-BowlOS-Api-Key\": this.apiKey,\n };\n if (method !== \"GET\") headers[\"Content-Type\"] = \"application/json\";\n if (bearer) headers[\"Authorization\"] = `Bearer ${bearer}`;\n\n const init: RequestInit = { method, headers };\n if (method !== \"GET\") init.body = JSON.stringify(args);\n\n let res: Response;\n try {\n res = await this.fetchFn(`${this.baseUrl}/${name}`, init);\n } catch (cause) {\n throw new BowlosApiError(\n BOWLOS_ERROR_CODES.NETWORK_ERROR,\n `Network request to \"${name}\" failed.`,\n 0,\n { cause },\n );\n }\n\n const retryHeader = res.headers.get(\"Retry-After\");\n const retryAfterSeconds = retryHeader ? Number(retryHeader) || undefined : undefined;\n\n let body: unknown = null;\n const text = await res.text();\n if (text) {\n try {\n body = JSON.parse(text);\n } catch {\n // Non-JSON (e.g. the router's plain \"No matching routes found\" 404).\n body = { ok: false, error: { code: BOWLOS_ERROR_CODES.NOT_FOUND, message: text.slice(0, 200) } };\n }\n }\n return { status: res.status, body, retryAfterSeconds };\n }\n\n /**\n * Call a gateway route by name (`POST /api/public/v1/<name>`), returning the\n * unwrapped `data`. Set `{ auth: true }` to attach the bearer token and\n * enable refresh-and-retry on an expired session.\n */\n async call<T = unknown>(\n name: string,\n args: Record<string, unknown> = {},\n opts: { auth?: boolean; method?: \"GET\" | \"POST\" } = {},\n ): Promise<T> {\n return this.callInternal<T>(name, args, opts.auth ?? false, false, opts.method ?? \"POST\");\n }\n\n private async callInternal<T>(\n name: string,\n args: Record<string, unknown>,\n auth: boolean,\n retried: boolean,\n method: \"GET\" | \"POST\",\n ): Promise<T> {\n const bearer = auth ? this.store.get()?.token : undefined;\n const { status, body, retryAfterSeconds } = await this.request(name, args, bearer, method);\n const env = (body ?? {}) as Envelope;\n\n if (env.ok === true) {\n // The data-passthrough routes delegate to functions that return their\n // OWN `{ schema_version, ok, data }` envelope, so the gateway double-wraps\n // them. Detect that inner envelope (uniquely marked by `schema_version`)\n // and unwrap it — surfacing an inner `{ ok:false }` as a thrown error.\n // Auth relays + the raw payment-intent payload have no `schema_version`,\n // so they pass straight through. Forward-compatible if the gateway is ever\n // changed to single-wrap (no inner envelope → nothing to unwrap).\n const data: unknown = env.data;\n if (data !== null && typeof data === \"object\" && \"schema_version\" in data && \"ok\" in data) {\n const inner = data as {\n ok: boolean;\n data?: unknown;\n error?: { code?: string; message?: string };\n };\n if (inner.ok === false) {\n throw new BowlosApiError(\n inner.error?.code ?? BOWLOS_ERROR_CODES.UNKNOWN,\n inner.error?.message ?? `Request to \"${name}\" failed.`,\n status,\n );\n }\n return inner.data as T;\n }\n return data as T;\n }\n\n const code =\n env.error?.code ??\n (status === 429\n ? BOWLOS_ERROR_CODES.RATE_LIMITED\n : status === 404\n ? BOWLOS_ERROR_CODES.NOT_FOUND\n : BOWLOS_ERROR_CODES.UNKNOWN);\n const message = env.error?.message ?? `Request to \"${name}\" failed (HTTP ${status}).`;\n\n if (auth && !retried && this.store.get() && looksLikeExpiredSession(status, code)) {\n const refreshed = await this.tryRefresh();\n if (refreshed) return this.callInternal<T>(name, args, auth, true, method);\n }\n\n throw new BowlosApiError(code, message, status, {\n retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : undefined,\n });\n }\n\n /** Exchange the stored refresh token for a fresh pair. Clears the session if\n * the refresh token is itself invalid/expired. Returns success. */\n private async tryRefresh(): Promise<boolean> {\n const current = this.store.get();\n if (!current?.refreshToken) return false;\n const { status, body } = await this.request(\"auth/refresh\", {\n refreshToken: current.refreshToken,\n });\n const env = (body ?? {}) as Envelope & { data?: { tokens?: Tokens } };\n if (status >= 200 && status < 300 && env.ok === true && env.data?.tokens) {\n this.store.set(env.data.tokens);\n return true;\n }\n this.store.set(null);\n return false;\n }\n\n // ── auth lifecycle ───────────────────────────────────────────────────────\n\n /** Sign an existing customer in; stores the session on success. */\n async signIn(email: string, password: string): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/signin\", { email, password });\n this.store.set(tokens);\n return tokens;\n }\n\n /**\n * Atomic sign-up (preferred): create the login AND the brand-scoped customer\n * profile in ONE server call, then store the session. Use this instead of\n * `signUp()` + `link()` — the two-step path can strand a login with no\n * customer profile if `link()` is missed or races the new session.\n */\n async register(\n email: string,\n password: string,\n profile: Omit<LinkProfile, \"email\">,\n ): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/register\", {\n email,\n password,\n ...profile,\n });\n this.store.set(tokens);\n return tokens;\n }\n\n /** Low-level: create a login only (no customer profile). Prefer `register()`;\n * if you use this you MUST follow with `link()` or the customer is orphaned. */\n async signUp(email: string, password: string): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/signup\", { email, password });\n this.store.set(tokens);\n return tokens;\n }\n\n /**\n * Forgot-password step 1: email a reset code to the address (if it has an\n * account at this center). Resolves regardless of whether the email exists —\n * the server never reveals that, to prevent account enumeration. No session\n * needed.\n */\n async requestPasswordReset(email: string): Promise<void> {\n await this.call(\"auth/request-reset\", { email });\n }\n\n /**\n * Forgot-password step 2: verify the emailed code + set a new password. On\n * success the customer is signed in (the session is stored), so the UI can\n * continue straight into the funnel. Throws `INVALID_RESET` on a bad/expired\n * code and `PASSWORD_TOO_WEAK` if the new password fails the policy.\n */\n async resetPassword(\n email: string,\n code: string,\n newPassword: string,\n ): Promise<Tokens> {\n const { tokens } = await this.call<{ tokens: Tokens }>(\"auth/reset\", {\n email,\n code,\n newPassword,\n });\n this.store.set(tokens);\n return tokens;\n }\n\n /** Link the signed-in auth user to a customer profile at the brand. */\n async link(profile: LinkProfile): Promise<unknown> {\n return this.call(\"auth/link\", { ...profile }, { auth: true });\n }\n\n /** End the session (best-effort server call; always clears locally). */\n async signOut(): Promise<void> {\n try {\n await this.call(\"auth/signout\", {}, { auth: true });\n } catch {\n // Even if the server call fails (expired token, network), drop locally.\n } finally {\n this.store.set(null);\n }\n }\n\n /** Session bootstrap: unauthenticated / authed-no-customer / linked.\n * GET — matches the gateway's `GET /auth/probe` route. */\n async probe(): Promise<AuthState> {\n const { state } = await this.call<{ state: AuthState }>(\n \"auth/probe\",\n {},\n { auth: true, method: \"GET\" },\n );\n return state;\n }\n\n /** The signed-in customer's profile, or null.\n * GET — matches the gateway's `GET /auth/me` route. */\n async me(): Promise<Customer | null> {\n const { customer } = await this.call<{ customer: Customer | null }>(\n \"auth/me\",\n {},\n { auth: true, method: \"GET\" },\n );\n return customer;\n }\n}\n\n/** Default transport: the global fetch, invoked on `globalThis` so browsers\n * don't throw \"Illegal invocation\". Fails only on first use if absent. */\nconst defaultFetch: FetchLike = (input, init) => {\n if (typeof globalThis.fetch !== \"function\") {\n throw new BowlosApiError(\n BOWLOS_ERROR_CODES.NETWORK_ERROR,\n \"No global fetch available. Pass `config.fetch`.\",\n 0,\n );\n }\n return globalThis.fetch(input, init);\n};\n\n/** Create a configured client. */\nexport function createBowlosClient(config: BowlosClientConfig): BowlosClient {\n return new BowlosClient(config);\n}\n","/**\n * Typed data surface for @bowlos/reservations — booking-funnel reads.\n *\n * Arg shapes mirror the gateway functions; result shapes type the headline\n * fields and pass the rest through (`[key: string]: unknown`), so the backend's\n * full breakdown can grow without an SDK release. Each read has a\n * framework-agnostic function here and a React hook in `hooks.tsx`, sharing\n * these types.\n *\n * This file is React-free, so it's exported from the core entry. The hooks\n * (React) live in `hooks.tsx` under the React entry.\n */\nimport type { BowlosClient } from \"./client\";\n\n/** Inputs for `checkAvailability`. Times are minutes-of-day in the Center's tz. */\nexport type AvailabilityArgs = {\n productId: string;\n dateISO: string;\n startMinuteOfDay: number;\n endMinuteOfDay: number;\n};\n\nexport interface AvailabilityResult {\n totalUnits: number;\n busyUnitIds: string[];\n}\n\nexport type PricingMode = \"per_unit_per_hour\" | \"per_person_per_hour\" | \"per_game\";\n\nexport type BookingAddonSelection = { addonId: string; quantity: number };\n\n/** A bookable add-on for a product (shoe rental, upgrades…). `rateMode` is how\n * it prices — `per_person` (× bowlers), `per_unit` (× lanes), or `flat` (once).\n * `defaultQuantityRule: \"one_per_guest\"` hints the natural quantity is the\n * party size; `\"manual\"` means the customer picks. */\nexport interface PublicAddon {\n id: string;\n displayId: string;\n name: string;\n description: string | null;\n priceCents: number;\n rateMode: \"per_person\" | \"per_unit\" | \"flat\";\n defaultQuantityRule: \"one_per_guest\" | \"manual\";\n}\n\n/** Inputs for `bookingPreview` (the authoritative price quote). */\nexport type BookingPreviewArgs = {\n centerId: string;\n productId: string;\n dateISO: string;\n startMinuteOfDay: number;\n endMinuteOfDay: number;\n mode: PricingMode;\n units?: number;\n persons?: number;\n games?: number;\n addons?: BookingAddonSelection[];\n shareToken?: string;\n subtypeId?: string;\n /** Reservation-mode event offer slug. Binds preview to that offer's event\n * price plan, tax override, and Center fee override/inheritance. */\n eventOfferSlug?: string;\n};\n\n/** The price quote. Headline fields are typed; the engine's full breakdown\n * (line items, discounts, tax, credit) is passed through. */\nexport interface BookingQuote {\n reservationFee: Record<string, unknown> | null;\n totalCentsPerPlan: Array<{ pricePlanId: string; totalCents: number }>;\n taxLinesPerPlan?: Array<{\n pricePlanId: string;\n taxLines: Array<{\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }>;\n taxTotalCents: number;\n }>;\n [key: string]: unknown;\n}\n\n/** Free units for a product/date/time window (anonymous). */\nexport function checkAvailability(\n client: BowlosClient,\n args: AvailabilityArgs,\n): Promise<AvailabilityResult> {\n return client.call<AvailabilityResult>(\"checkAvailability\", args);\n}\n\n/** Authoritative price quote for the chosen inputs. Anonymous by default\n * (the center's standard online price). Pass `{ auth: true }` when the\n * customer has a session so the quote includes member rate + account\n * credit — headless sites must opt in, since the core doesn't track\n * session state. (The `<BookingFlow>` reference + `useBookingPreview`\n * hook do this automatically off `useAccount`.) */\nexport function bookingPreview(\n client: BowlosClient,\n args: BookingPreviewArgs,\n opts?: { auth?: boolean },\n): Promise<BookingQuote> {\n return client.call<BookingQuote>(\"bookingPreview\", args, {\n auth: opts?.auth ?? false,\n });\n}\n\n/** Add-ons available for a product (shoe rental, upgrades…). Anonymous-callable;\n * feed the customer's picks back as `addons` on the preview + the booking. */\nexport function listAddons(\n client: BowlosClient,\n args: { productId: string },\n): Promise<PublicAddon[]> {\n return client.call<PublicAddon[]>(\"listPublicAddons\", args);\n}\n\n/** Inputs for `availableStartTimes`. */\nexport type StartTimesArgs = {\n productId: string;\n dateISO: string;\n /** Booking length, to leave room before close. Default 60 on the server. */\n durationMinutes?: number;\n /** Grid step in minutes. Default 30 on the server. */\n stepMinutes?: number;\n mode?: PricingMode;\n};\n\n/** The bookable start times (minute-of-day, ascending) for a product on a date:\n * within operating hours, past the booking buffer, and backed by a real price\n * plan (same pricing engine the quote uses). Anonymous-callable. */\nexport function listStartTimes(\n client: BowlosClient,\n args: StartTimesArgs,\n): Promise<number[]> {\n return client.call<number[]>(\"availableStartTimes\", args);\n}\n\n/** Convenience: free units = total minus the busy set (never negative). */\nexport function availableUnitCount(availability: AvailabilityResult): number {\n return Math.max(0, availability.totalUnits - availability.busyUnitIds.length);\n}\n\n// ── booking flow (hold → pay → confirm) ──────────────────────────────────────\n\n/** Customer identity for a booking (collected in the booking form; the server\n * links/creates the customer per the booking-flow-only signup rule). */\nexport type BookingCustomer = {\n fullName: string;\n email: string;\n mobile?: string;\n marketingOptIn: boolean;\n};\n\n/** Inputs for `createAnonymousBooking` — places the inventory hold. */\nexport type CreateBookingArgs = {\n centerId: string;\n productId: string;\n dateISO: string;\n startMinuteOfDay: number;\n endMinuteOfDay: number;\n mode: PricingMode;\n units?: number;\n persons?: number;\n games?: number;\n addons?: BookingAddonSelection[];\n customer: BookingCustomer;\n /** Apply account credit (requires a signed-in customer). */\n applyCredit?: boolean;\n /** Idempotency key for the create. The SDK generates one if omitted. */\n idempotencyKey?: string;\n shareToken?: string;\n subtypeId?: string;\n /** Reservation-mode event offer slug. Must match the preview slug. */\n eventOfferSlug?: string;\n};\n\n/** Result of placing a booking. The hold→pay path returns `checkoutRefToken`\n * with `requiresPayment: true`; a credit-covered / $0 booking returns the\n * materialized `reservationId` + `reservationDisplayId` with\n * `requiresPayment: false`. Headline fields typed; the rest passes through. */\nexport interface BookingHold {\n checkoutRefToken?: string;\n reservationId?: string | null;\n reservationDisplayId?: string | null;\n requiresPayment: boolean;\n finalCents: number;\n appliedCreditCents: number;\n paidCents?: number;\n holdExpiresAt?: number;\n replayed?: boolean;\n [key: string]: unknown;\n}\n\nexport type CheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid_materialized\"\n | \"expired\"\n | \"payment_failed_retryable\"\n | \"abandoned\";\n\nexport interface CheckoutStatusResult {\n status: CheckoutStatus;\n reservationDisplayId: string | null;\n reservationId: string | null;\n}\n\n/** Stripe (Connect) PaymentIntent data for the UI layer to render Elements.\n * The SDK does NOT load Stripe.js — initialize it with `connectedAccountId`\n * (the operator's connected account) + `clientSecret`. */\nexport interface PaymentIntentInfo {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n customerId: string;\n ephemeralKey: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** The minimal shape `<BowlosPaymentForm>` needs to confirm a payment on the\n * operator's connected account. `PaymentIntentInfo` (booking) and the buy-flow\n * intents both satisfy it; a recurring membership passes the subscription's\n * first-invoice `clientSecret` here too. */\nexport interface ConnectedPaymentInput {\n clientSecret: string;\n connectedAccountId: string;\n customerSessionClientSecret?: string;\n /** Full Test Mode (2026-06-23): the PI's Stripe environment. `<BowlosPaymentForm>`\n * loads the matching publishable key (test vs live) when `testPublishableKey`\n * is supplied. Absent → \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n// ── headless purchases (game passes; packages + memberships follow) ──────────\n\n/** Inputs for a game-pass purchase. The SDK generates an idempotency key if omitted. */\nexport type GameCardPurchaseArgs = {\n templateId: string;\n idempotencyKey?: string;\n shareToken?: string;\n /** v0.32.0: when set, the buy redeems this flash-sale item at its sale price\n * (the flash sale must be Live; the server validates the item matches). */\n flashSaleItemId?: string;\n};\n\n/** The connected-account PaymentIntent for a game-pass purchase. Confirm it with\n * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.\n * Poll `getGameCardStatus(refToken)` for materialization. */\nexport interface GameCardPurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n refToken: string | null;\n cardId: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Buy a game pass — mints the connected-account PaymentIntent (requires a\n * signed-in customer; the charge lands on the operator's connected account). */\nexport function createGameCardOrder(\n client: BowlosClient,\n args: GameCardPurchaseArgs,\n): Promise<GameCardPurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<GameCardPurchaseIntent>(\n \"createGameCardPaymentIntent\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\nexport type GameCardCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid_materialized\"\n | \"expired\"\n | \"payment_failed_retryable\"\n | \"abandoned\";\n\nexport interface GameCardStatusResult {\n status: GameCardCheckoutStatus;\n gameCardId: string | null;\n}\n\n/** Poll a game-pass purchase to materialization (by the create's `refToken`). */\nexport function getGameCardStatus(\n client: BowlosClient,\n refToken: string,\n): Promise<GameCardStatusResult> {\n return client.call<GameCardStatusResult>(\n \"getGameCardCheckoutStatus\",\n { refToken },\n { auth: true },\n );\n}\n\n/** Inputs for an itemized game-pass quote. A pass has no config (no date/qty),\n * so it's just the template (+ an optional share token for a private pass).\n * The selling Center is resolved server-side from the customer's home Center. */\nexport type GameCardPreviewArgs = {\n templateId: string;\n shareToken?: string;\n /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */\n flashSaleItemId?: string;\n};\n\n/** Server-computed itemized quote for a game-pass purchase — the base price,\n * tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless \"Review\" step. Computed by the SAME engine as the\n * PaymentIntent, so it never diverges from what the customer is charged. */\nexport interface GameCardPreviewResult {\n subtotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a game-pass purchase WITHOUT creating a PaymentIntent —\n * feeds the Review step. Requires a signed-in customer (so tax exemptions +\n * the resolved home Center match the eventual charge). */\nexport function previewGameCard(\n client: BowlosClient,\n args: GameCardPreviewArgs,\n): Promise<GameCardPreviewResult> {\n return client.call<GameCardPreviewResult>(\n \"previewGameCardOrder\",\n args,\n { auth: true },\n );\n}\n\nexport type EventTicketPreviewArgs = {\n eventOfferId: string;\n quantity: number;\n /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */\n flashSaleItemId?: string;\n};\n\nexport interface EventTicketPreviewResult {\n eventName: string;\n eventDate: string;\n quantity: number;\n unitPriceCents: number;\n subtotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a ticket-mode event offer WITHOUT creating a\n * PaymentIntent. Requires a signed-in customer so tax exemptions match the\n * eventual charge. */\nexport function previewEventTicket(\n client: BowlosClient,\n args: EventTicketPreviewArgs,\n): Promise<EventTicketPreviewResult> {\n return client.call<EventTicketPreviewResult>(\n \"previewEventTicketOrder\",\n args,\n { auth: true },\n );\n}\n\nexport type EventTicketPurchaseArgs = {\n eventOfferId: string;\n quantity: number;\n idempotencyKey?: string;\n /** v0.32.0: redeem this flash-sale item at its sale price. */\n flashSaleItemId?: string;\n};\n\n/** The connected-account PaymentIntent for a ticket-mode event purchase.\n * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` +\n * the customer session. After payment, read the receipt with `getMyEventOrder`. */\nexport interface EventTicketPurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n orderId: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Buy tickets for a ticket-mode event offer — mints the connected-account\n * PaymentIntent. Requires a signed-in customer so taxes and account ownership\n * match the preview. */\nexport function createEventTicketOrder(\n client: BowlosClient,\n args: EventTicketPurchaseArgs,\n): Promise<EventTicketPurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<EventTicketPurchaseIntent>(\n \"createEventTicketPaymentIntent\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\nexport type EventTicketCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid\"\n | \"cancelled\"\n | \"refunded\";\n\nexport interface EventTicketStatusResult {\n status: EventTicketCheckoutStatus;\n orderId: string | null;\n}\n\n/** Poll a ticket-mode event purchase by the order id returned from create. */\nexport function getEventTicketStatus(\n client: BowlosClient,\n orderId: string,\n): Promise<EventTicketStatusResult> {\n return client.call<EventTicketStatusResult>(\n \"getEventTicketCheckoutStatus\",\n { orderId },\n { auth: true },\n );\n}\n\n// ── headless purchases: packages ─────────────────────────────────────────────\n\n/** Inputs for a package purchase. The SDK generates an idempotency key if omitted.\n * `scheduledDate` is `YYYY-MM-DD` in the Center's timezone; `scheduledStartMinute`\n * is minutes-from-midnight (e.g. 1050 = 5:30 PM) and MUST be one of the package's\n * bookable start times — see HEADLESS.md → \"Buying a package\" for computing them. */\nexport type PackagePurchaseArgs = {\n packageId: string;\n centerId: string;\n quantity: number;\n optionalAddons?: { addonId: string; quantity: number }[];\n scheduledDate: string;\n scheduledStartMinute: number;\n idempotencyKey?: string;\n shareToken?: string;\n /** v0.32.0: redeem this flash-sale item at its sale price. */\n flashSaleItemId?: string;\n};\n\n/** The connected-account PaymentIntent for a package purchase. Confirm it with\n * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.\n * Poll `getPackageStatus(orderId)` for materialization. */\nexport interface PackagePurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n orderId: string;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Group id for the inventory hold the order created — subscribe with\n * `getMyHoldGroup` to render the checkout countdown if you choose to. */\n inventoryHoldGroupId?: string;\n}\n\n/** Buy a package — mints the connected-account PaymentIntent (requires a\n * signed-in customer; the charge lands on the operator's connected account). */\nexport function createPackageOrder(\n client: BowlosClient,\n args: PackagePurchaseArgs,\n): Promise<PackagePurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<PackagePurchaseIntent>(\n \"createPackagePaymentIntent\",\n { ...args, optionalAddons: args.optionalAddons ?? [], idempotencyKey },\n { auth: true },\n );\n}\n\nexport type PackageCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid\"\n | \"cancelled\"\n | \"refunded\";\n\nexport interface PackageStatusResult {\n status: PackageCheckoutStatus;\n orderId: string | null;\n}\n\n/** Poll a package purchase to materialization (by the create's `orderId`). */\nexport function getPackageStatus(\n client: BowlosClient,\n orderId: string,\n): Promise<PackageStatusResult> {\n return client.call<PackageStatusResult>(\n \"getPackageCheckoutStatus\",\n { orderId },\n { auth: true },\n );\n}\n\n/** Inputs for an itemized package quote — the buy config minus the schedule\n * (price doesn't depend on date/time; the schedule only affects the eventual\n * create's slot validation). */\nexport type PackagePreviewArgs = {\n packageId: string;\n centerId: string;\n quantity: number;\n optionalAddons?: { addonId: string; quantity: number }[];\n shareToken?: string;\n /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */\n flashSaleItemId?: string;\n};\n\n/** Server-computed itemized quote for a package order — base, optional add-ons,\n * tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless \"Review\" step. Computed by the SAME engine as the\n * PaymentIntent, so it never diverges from what the customer is charged. */\nexport interface PackagePreviewResult {\n baseTotalCents: number;\n addons: { addonId: string; name: string; quantity: number; lineCents: number }[];\n addonsTotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a package order WITHOUT creating a PaymentIntent — feeds\n * the Review step. Requires a signed-in customer (so tax exemptions match the\n * eventual charge). */\nexport function previewPackage(\n client: BowlosClient,\n args: PackagePreviewArgs,\n): Promise<PackagePreviewResult> {\n return client.call<PackagePreviewResult>(\n \"previewPackageOrder\",\n { ...args, optionalAddons: args.optionalAddons ?? [] },\n { auth: true },\n );\n}\n\n// ── headless purchases: memberships (one-time + recurring) ───────────────────\n\n/** Inputs for an itemized membership quote. A membership has no config (no\n * date/qty), so it's just the template (+ an optional share token for a private\n * membership). The selling Center is resolved server-side from the customer's\n * home Center. Shared by the one-time and recurring previews. */\nexport type MembershipPreviewArgs = {\n templateId: string;\n shareToken?: string;\n /** v0.32.0: reflect the flash sale price in the Review (one-time only). */\n flashSaleItemId?: string;\n};\n\n/** Server-computed itemized quote for a one-time membership purchase — the dues,\n * the one-time setup (joining) fee, tax lines, the selling Center's booking fee,\n * and the authoritative grand total. Drives the headless \"Review\" step. Computed\n * by the SAME engine as the PaymentIntent, so it never diverges from what the\n * customer is charged. */\nexport interface MembershipPreviewResult {\n duesCents: number;\n setupFeeCents: number;\n subtotalCents: number;\n taxLines: {\n rateId: string;\n label: string;\n rateBasisPoints: number;\n mode: \"added\" | \"included\";\n taxableBaseCents: number;\n taxCents: number;\n }[];\n taxTotalCents: number;\n reservationFeeCents: number | null;\n reservationFeeLabel: string | null;\n grandTotalCents: number;\n}\n\n/** Itemized quote for a one-time membership purchase WITHOUT creating a\n * PaymentIntent — feeds the Review step. Requires a signed-in customer (so tax\n * exemptions + the resolved home Center match the eventual charge). */\nexport function previewMembership(\n client: BowlosClient,\n args: MembershipPreviewArgs,\n): Promise<MembershipPreviewResult> {\n return client.call<MembershipPreviewResult>(\n \"previewMembershipOrder\",\n args,\n { auth: true },\n );\n}\n\n/** Inputs for a one-time membership purchase. The SDK generates an idempotency\n * key if omitted. */\nexport type MembershipPurchaseArgs = {\n templateId: string;\n idempotencyKey?: string;\n shareToken?: string;\n /** v0.32.0: redeem this flash-sale item at its sale price (one-time only). */\n flashSaleItemId?: string;\n};\n\n/** The connected-account PaymentIntent for a one-time membership purchase.\n * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` + the\n * customer session. Poll `getMembershipStatus(refToken)` for materialization. */\nexport interface MembershipPurchaseIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n refToken: string | null;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Buy a one-time membership — mints the connected-account PaymentIntent\n * (requires a signed-in customer; the charge lands on the operator's connected\n * account). */\nexport function createMembershipOrder(\n client: BowlosClient,\n args: MembershipPurchaseArgs,\n): Promise<MembershipPurchaseIntent> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<MembershipPurchaseIntent>(\n \"createMembershipPaymentIntent\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\nexport type MembershipCheckoutStatus =\n | \"not_found\"\n | \"pending_payment\"\n | \"paid_materialized\"\n | \"expired\"\n | \"payment_failed_retryable\"\n | \"abandoned\";\n\nexport interface MembershipStatusResult {\n status: MembershipCheckoutStatus;\n membershipId: string | null;\n}\n\n/** Poll a one-time membership purchase to materialization (by the create's\n * `refToken`). */\nexport function getMembershipStatus(\n client: BowlosClient,\n refToken: string,\n): Promise<MembershipStatusResult> {\n return client.call<MembershipStatusResult>(\n \"getMembershipCheckoutStatus\",\n { refToken },\n { auth: true },\n );\n}\n\n/** Server-computed itemized quote for a RECURRING membership subscription — the\n * same fields as the one-time quote (what's charged today: dues + one-time setup\n * fee + tax + the selling Center's fee), PLUS `recurringTotalCents` (what each\n * renewal charges) and the `cadence`. Drives the recurring \"Review\" step's\n * \"Due today\" + \"Auto-renews at\" lines. Computed by the SAME engine as the\n * subscription's first invoice, so it never diverges. */\nexport interface MembershipSubscriptionPreviewResult extends MembershipPreviewResult {\n recurringTotalCents: number;\n cadence: \"monthly\" | \"annual\" | \"one_time\";\n}\n\n/** Itemized quote for a recurring membership subscription WITHOUT creating the\n * subscription — feeds the Review step. Requires a signed-in customer (so tax\n * exemptions + the resolved home Center match the eventual charge). */\nexport function previewMembershipSubscription(\n client: BowlosClient,\n args: MembershipPreviewArgs,\n): Promise<MembershipSubscriptionPreviewResult> {\n return client.call<MembershipSubscriptionPreviewResult>(\n \"previewMembershipSubscriptionOrder\",\n args,\n { auth: true },\n );\n}\n\n/** Inputs for a recurring membership subscription. (No idempotency key — the\n * subscription itself is the dedupe anchor; the buy is gated to one active\n * membership per customer.) */\nexport type MembershipSubscriptionArgs = {\n templateId: string;\n shareToken?: string;\n};\n\n/** The connected-account first-invoice payment for a recurring membership\n * subscription. Confirm `clientSecret` with `<BowlosPaymentForm>` — it carries\n * `connectedAccountId` + the customer session. There is NO refToken: the\n * subscription materializes via webhook, so re-query `useMyMemberships` after\n * payment rather than polling. */\nexport interface MembershipSubscriptionIntent {\n subscriptionId: string;\n clientSecret: string;\n amountCents: number;\n customerSessionClientSecret: string;\n connectedAccountId: string;\n /** Full Test Mode (2026-06-23): the Stripe environment this PaymentIntent was\n * created in. Load Stripe.js with the matching publishable key\n * (`pk_test_…` for \"test\", `pk_live_…` for \"live\") scoped to\n * `connectedAccountId`. `<BowlosPaymentForm>` picks it for you when you pass\n * `testPublishableKey`. Absent on older gateway responses → treat as \"live\". */\n stripeMode?: \"test\" | \"live\";\n}\n\n/** Start a recurring membership subscription — mints the subscription + its\n * first-invoice PaymentIntent on the operator's connected account (requires a\n * signed-in customer). Confirm the returned `clientSecret`; the subscription\n * materializes via webhook. */\nexport function createMembershipSubscriptionOrder(\n client: BowlosClient,\n args: MembershipSubscriptionArgs,\n): Promise<MembershipSubscriptionIntent> {\n return client.call<MembershipSubscriptionIntent>(\n \"createMembershipSubscription\",\n args,\n { auth: true },\n );\n}\n\n/** Browser/Node-safe idempotency key for booking creates. */\nexport function generateIdempotencyKey(): string {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n return `idem_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;\n}\n\n/** Place the inventory hold + open a checkout. Sends the session when present\n * (member rates + account credit); falls back to anonymous. */\nexport function createBooking(\n client: BowlosClient,\n args: CreateBookingArgs,\n): Promise<BookingHold> {\n const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();\n return client.call<BookingHold>(\n \"createAnonymousBooking\",\n { ...args, idempotencyKey },\n { auth: true },\n );\n}\n\n/** Mint the Stripe Connect PaymentIntent for a held checkout (by refToken). */\nexport function createCheckoutPaymentIntent(\n client: BowlosClient,\n refToken: string,\n): Promise<PaymentIntentInfo> {\n return client.call<PaymentIntentInfo>(\n \"createCheckoutPaymentIntent\",\n { refToken },\n { auth: true },\n );\n}\n\n/** Poll the hold→pay→materialize state for a checkout (by refToken). */\nexport function getCheckoutStatus(\n client: BowlosClient,\n refToken: string,\n): Promise<CheckoutStatusResult> {\n return client.call<CheckoutStatusResult>(\"getCheckoutStatus\", { refToken }, { auth: true });\n}\n\n/** Release the hold + cancel the checkout (the \"Back\" button). */\nexport function abandonCheckout(\n client: BowlosClient,\n refToken: string,\n): Promise<{ ok: boolean }> {\n return client.call<{ ok: boolean }>(\"abandonCheckout\", { refToken }, { auth: true });\n}\n"]}