@bowlos/reservations 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/react.tsx","../src/hooks.tsx","../src/data.ts","../src/use-booking-flow.tsx"],"names":["createContext","useRef","useContext","useState","useCallback","useEffect"],"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,EAIrB,iBAAA,EAAmB,mBAAA;AAAA,EACnB,aAAA,EAAe,eAAA;AAAA,EACf,SAAA,EAAW,WAAA;AAAA,EAKO;AAAA,EAElB,aAAA,EAAe,eAAA;AAAA,EACf,OAAA,EAAS;AACX,CAAA;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,MAAA;AACd,IAAA,IAAA,CAAK,oBAAoB,OAAA,CAAQ,iBAAA;AAEjC,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,eAAA,CAAe,SAAS,CAAA;AAAA,EACtD;AAAA;AA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A;AAAA,IACA,WAAA;AAAA,IACA,eAAA,EAAiB,IAAA,GAAO,IAAA,CAAK,eAAA,GAAkB,IAAA;AAAA,IAC/C,KAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"react.cjs","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 /** Create a login (the auth half of sign-up); stores the session. Follow with\n * `link()` to attach the customer profile. */\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 /** 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 * React layer for @bowlos/reservations.\n *\n * `<BowlosProvider>` holds one `BowlosClient`; `useAccount()` manages the\n * customer session (probe on mount, sign-in/up/link/out, current customer);\n * `useBowlosQuery()` is the generic read hook the typed data hooks\n * (`useAvailability`, `useBookingFlow`, …) will build on next.\n *\n * Lives in its own module so non-React consumers of the core never pull React.\n * (The `@bowlos/reservations/react` export subpath is wired with the publish build.)\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { BowlosClient, createBowlosClient } from \"./client\";\nimport { BowlosApiError } from \"./errors\";\nimport type { AuthState, BowlosClientConfig, Customer, LinkProfile } from \"./types\";\n\nconst BowlosContext = createContext<BowlosClient | null>(null);\n\nexport interface BowlosProviderProps {\n /** A prebuilt client, or pass `config` to have one created and memoized. */\n client?: BowlosClient;\n config?: BowlosClientConfig;\n children: ReactNode;\n}\n\nexport function BowlosProvider({ client, config, children }: BowlosProviderProps) {\n const ref = useRef<BowlosClient | null>(client ?? null);\n if (!ref.current) {\n if (!config) {\n throw new Error(\"BowlosProvider requires either a `client` or a `config`.\");\n }\n ref.current = createBowlosClient(config);\n }\n return <BowlosContext.Provider value={ref.current}>{children}</BowlosContext.Provider>;\n}\n\nexport function useBowlosClient(): BowlosClient {\n const client = useContext(BowlosContext);\n if (!client) {\n throw new Error(\"useBowlosClient must be used within a <BowlosProvider>.\");\n }\n return client;\n}\n\n// ── useAccount ──────────────────────────────────────────────────────────────\n\nexport type AccountStatus = \"loading\" | AuthState;\n\nexport interface UseAccountResult {\n status: AccountStatus;\n customer: Customer | null;\n error: BowlosApiError | null;\n signIn: (email: string, password: string) => Promise<void>;\n signUp: (email: string, password: string) => Promise<void>;\n link: (profile: LinkProfile) => Promise<void>;\n signOut: () => Promise<void>;\n refresh: () => Promise<void>;\n}\n\n/** Customer session state + actions. Probes once on mount; each action\n * re-probes so `status`/`customer` stay current. */\nexport function useAccount(): UseAccountResult {\n const client = useBowlosClient();\n const [status, setStatus] = useState<AccountStatus>(\"loading\");\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const refresh = useCallback(async () => {\n try {\n const state = await client.probe();\n setStatus(state);\n setCustomer(state === \"linked\" ? await client.me() : null);\n setError(null);\n } catch (e) {\n setStatus(\"unauthenticated\");\n setCustomer(null);\n if (e instanceof BowlosApiError) setError(e);\n }\n }, [client]);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n const run = useCallback(\n async (action: () => Promise<unknown>) => {\n setError(null);\n try {\n await action();\n await refresh();\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n }\n },\n [refresh],\n );\n\n const signIn = useCallback(\n (email: string, password: string) => run(() => client.signIn(email, password)),\n [client, run],\n );\n const signUp = useCallback(\n (email: string, password: string) => run(() => client.signUp(email, password)),\n [client, run],\n );\n const link = useCallback((profile: LinkProfile) => run(() => client.link(profile)), [client, run]);\n const signOut = useCallback(() => run(() => client.signOut()), [client, run]);\n\n return { status, customer, error, signIn, signUp, link, signOut, refresh };\n}\n\n// ── useBowlosQuery ────────────────────────────────────────────────────────────\n\nexport interface UseQueryOptions {\n /** Send the customer bearer token (for session-scoped reads). */\n auth?: boolean;\n /** Skip fetching until true. Defaults to true. */\n enabled?: boolean;\n}\n\nexport interface UseQueryResult<T> {\n data: T | null;\n error: BowlosApiError | null;\n loading: boolean;\n refetch: () => Promise<void>;\n}\n\n/** Generic read hook over a gateway route. The typed data hooks\n * (`useAvailability`, etc.) will wrap this with route names + arg types. */\nexport function useBowlosQuery<T = unknown>(\n name: string,\n args: Record<string, unknown> = {},\n options: UseQueryOptions = {},\n): UseQueryResult<T> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const enabled = options.enabled ?? true;\n const [data, setData] = useState<T | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(enabled);\n // Stabilize the args object across renders so the effect doesn't loop.\n const argsKey = JSON.stringify(args);\n\n const refetch = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<T>(name, JSON.parse(argsKey) as Record<string, unknown>, {\n auth,\n });\n setData(result);\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setData(null);\n } finally {\n setLoading(false);\n }\n }, [client, name, argsKey, auth]);\n\n useEffect(() => {\n if (enabled) void refetch();\n }, [enabled, refetch]);\n\n return { data, error, loading, refetch };\n}\n","/**\n * Typed React data hooks for the booking funnel, built on `useBowlosQuery`.\n * Same arg/result types as the framework-agnostic functions in `data.ts`.\n */\nimport { useBowlosQuery, type UseQueryOptions, type UseQueryResult } from \"./react\";\nimport type {\n AvailabilityArgs,\n AvailabilityResult,\n BookingPreviewArgs,\n BookingQuote,\n} from \"./data\";\nimport type {\n BrandScoped,\n FlashBookingOptionsArgs,\n FlashSaleArgs,\n MembershipDetailArgs,\n ReservationDetailArgs,\n} from \"./account\";\n\n/** Live free-unit availability for a product / date / time window. */\nexport function useAvailability(\n args: AvailabilityArgs,\n options?: UseQueryOptions,\n): UseQueryResult<AvailabilityResult> {\n return useBowlosQuery<AvailabilityResult>(\"checkAvailability\", args, options);\n}\n\n/** Authoritative price quote for the chosen booking inputs. */\nexport function useBookingPreview(\n args: BookingPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<BookingQuote> {\n return useBowlosQuery<BookingQuote>(\"bookingPreview\", args, options);\n}\n\n// ── account (require a signed-in customer) ───────────────────────────────────\n// Results are generic (`<T = unknown>`) — parameterize with your own shape.\n\n/** The signed-in customer's reservations. */\nexport function useMyReservations<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyReservations\", args, { ...options, auth: true });\n}\n\n/** One of the customer's reservations, by displayId. */\nexport function useMyReservationDetail<T = unknown>(\n args: ReservationDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyReservationDetail\", args, { ...options, auth: true });\n}\n\n/** The customer's memberships. */\nexport function useMyMemberships<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyMemberships\", args, { ...options, auth: true });\n}\n\n/** One membership's detail. */\nexport function useMyMembershipDetail<T = unknown>(\n args: MembershipDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyMembershipDetail\", args, { ...options, auth: true });\n}\n\n/** Loyalty tier + points. */\nexport function useMyLoyalty<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyLoyalty\", args, { ...options, auth: true });\n}\n\n/** Account credit balance + ledger. */\nexport function useMyCredits<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyCredits\", args, { ...options, auth: true });\n}\n\n/** Issued wallet passes. */\nexport function useMyPasses<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyPasses\", args, { ...options, auth: true });\n}\n\n// ── flash sales (session-aware: members see prices) ──────────────────────────\n\n/** The public flash-sale page (members see prices; anonymous gets the locked view). */\nexport function useFlashSale<T = unknown>(\n args: FlashSaleArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicFlashSaleBySlug\", args, { ...options, auth: true });\n}\n\n/** Per-start-hour options for a flash-sale reservation item (members only). */\nexport function useFlashSaleBookingOptions<T = unknown>(\n args: FlashBookingOptionsArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getFlashSaleBookingOptions\", args, { ...options, auth: true });\n}\n","/**\n * 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/** 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};\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 [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; a signed-in\n * session unlocks member rates + account credit). */\nexport function bookingPreview(\n client: BowlosClient,\n args: BookingPreviewArgs,\n): Promise<BookingQuote> {\n return client.call<BookingQuote>(\"bookingPreview\", 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};\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}\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","/**\n * useBookingFlow — the hold → pay → confirm state machine.\n *\n * Orchestrates the booking funnel and HANDS the Stripe (Connect) payment data\n * to the UI layer; it does NOT load Stripe.js. After `preparePayment()`, render\n * Stripe Elements from `paymentIntent` (initialize Stripe with\n * `connectedAccountId` + `clientSecret`), let the customer pay, then\n * `startPolling()` until the webhook materializes the booking\n * (`status: \"confirmed\"`).\n *\n * Flow:\n * startHold(args) → \"held\" (requiresPayment) | \"confirmed\" (credit covered)\n * preparePayment() → \"awaitingPayment\" (+ paymentIntent)\n * [consumer renders Stripe Elements + the customer pays]\n * startPolling() → \"confirmed\" | \"expired\" | \"failed\" | \"abandoned\"\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useBowlosClient } from \"./react\";\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport {\n abandonCheckout as abandonCheckoutCall,\n createBooking as createBookingCall,\n createCheckoutPaymentIntent as createPaymentIntentCall,\n getCheckoutStatus as getCheckoutStatusCall,\n type BookingHold,\n type CheckoutStatusResult,\n type CreateBookingArgs,\n type PaymentIntentInfo,\n} from \"./data\";\n\nexport type BookingFlowStatus =\n | \"idle\"\n | \"holding\"\n | \"held\"\n | \"preparingPayment\"\n | \"awaitingPayment\"\n | \"confirmed\"\n | \"expired\"\n | \"failed\"\n | \"abandoned\"\n | \"error\";\n\nexport interface BookingReservationRef {\n reservationId: string | null;\n reservationDisplayId: string | null;\n}\n\nexport interface UseBookingFlowResult {\n status: BookingFlowStatus;\n hold: BookingHold | null;\n refToken: string | null;\n paymentIntent: PaymentIntentInfo | null;\n reservation: BookingReservationRef | null;\n requiresPayment: boolean | null;\n error: BowlosApiError | null;\n startHold: (args: CreateBookingArgs) => Promise<void>;\n preparePayment: () => Promise<PaymentIntentInfo | null>;\n pollStatus: () => Promise<CheckoutStatusResult | null>;\n startPolling: (intervalMs?: number) => void;\n stopPolling: () => void;\n abandon: () => Promise<void>;\n reset: () => void;\n}\n\nconst DEFAULT_POLL_MS = 2500;\n\nexport function useBookingFlow(): UseBookingFlowResult {\n const client = useBowlosClient();\n const [status, setStatus] = useState<BookingFlowStatus>(\"idle\");\n const [hold, setHold] = useState<BookingHold | null>(null);\n const [refToken, setRefToken] = useState<string | null>(null);\n const [paymentIntent, setPaymentIntent] = useState<PaymentIntentInfo | null>(null);\n const [reservation, setReservation] = useState<BookingReservationRef | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n // Mirror of refToken for the polling interval (avoids a stale closure).\n const refTokenRef = useRef<string | null>(null);\n const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const stopPolling = useCallback(() => {\n if (pollRef.current !== null) {\n clearInterval(pollRef.current);\n pollRef.current = null;\n }\n }, []);\n\n useEffect(() => stopPolling, [stopPolling]); // clear the interval on unmount\n\n const reset = useCallback(() => {\n stopPolling();\n refTokenRef.current = null;\n setRefToken(null);\n setHold(null);\n setPaymentIntent(null);\n setReservation(null);\n setError(null);\n setStatus(\"idle\");\n }, [stopPolling]);\n\n const applyStatus = useCallback(\n (s: CheckoutStatusResult) => {\n switch (s.status) {\n case \"paid_materialized\":\n setReservation({\n reservationId: s.reservationId,\n reservationDisplayId: s.reservationDisplayId,\n });\n setStatus(\"confirmed\");\n stopPolling();\n break;\n case \"expired\":\n setStatus(\"expired\");\n stopPolling();\n break;\n case \"abandoned\":\n setStatus(\"abandoned\");\n stopPolling();\n break;\n case \"payment_failed_retryable\":\n setStatus(\"failed\");\n stopPolling();\n break;\n case \"not_found\":\n setError(new BowlosApiError(BOWLOS_ERROR_CODES.NOT_FOUND, \"Checkout not found.\", 404));\n setStatus(\"error\");\n stopPolling();\n break;\n case \"pending_payment\":\n default:\n break; // keep waiting\n }\n },\n [stopPolling],\n );\n\n const startHold = useCallback(\n async (args: CreateBookingArgs) => {\n stopPolling();\n setError(null);\n setPaymentIntent(null);\n setReservation(null);\n setStatus(\"holding\");\n try {\n const h = await createBookingCall(client, args);\n setHold(h);\n const rt = typeof h.checkoutRefToken === \"string\" ? h.checkoutRefToken : null;\n refTokenRef.current = rt;\n setRefToken(rt);\n if (!h.requiresPayment) {\n setReservation({\n reservationId: h.reservationId ?? null,\n reservationDisplayId: h.reservationDisplayId ?? null,\n });\n setStatus(\"confirmed\");\n } else if (rt) {\n setStatus(\"held\");\n } else {\n setError(\n new BowlosApiError(\n \"UNSUPPORTED_BOOKING_PATH\",\n \"This booking requires payment but no checkout hold was returned.\",\n 0,\n ),\n );\n setStatus(\"error\");\n }\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n }\n },\n [client, stopPolling],\n );\n\n const preparePayment = useCallback(async (): Promise<PaymentIntentInfo | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n setError(null);\n setStatus(\"preparingPayment\");\n try {\n const pi = await createPaymentIntentCall(client, rt);\n setPaymentIntent(pi);\n setStatus(\"awaitingPayment\");\n return pi;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n return null;\n }\n }, [client]);\n\n const pollStatus = useCallback(async (): Promise<CheckoutStatusResult | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n try {\n const s = await getCheckoutStatusCall(client, rt);\n applyStatus(s);\n return s;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n return null;\n }\n }, [client, applyStatus]);\n\n const startPolling = useCallback(\n (intervalMs: number = DEFAULT_POLL_MS) => {\n stopPolling();\n void pollStatus();\n pollRef.current = setInterval(() => {\n void pollStatus();\n }, intervalMs);\n },\n [pollStatus, stopPolling],\n );\n\n const abandon = useCallback(async () => {\n stopPolling();\n const rt = refTokenRef.current;\n if (rt) {\n try {\n await abandonCheckoutCall(client, rt);\n } catch {\n // best-effort: the hold also frees itself on its TTL\n }\n }\n setStatus(\"abandoned\");\n }, [client, stopPolling]);\n\n return {\n status,\n hold,\n refToken,\n paymentIntent,\n reservation,\n requiresPayment: hold ? hold.requiresPayment : null,\n error,\n startHold,\n preparePayment,\n pollStatus,\n startPolling,\n stopPolling,\n abandon,\n reset,\n };\n}\n"]}
@@ -0,0 +1,94 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { A as AuthState, j as BowlosClient, k as BowlosClientConfig, p as Customer, h as BowlosApiError, L as LinkProfile, a as AvailabilityArgs, b as AvailabilityResult, f as BookingPreviewArgs, g as BookingQuote, r as FlashSaleArgs, q as FlashBookingOptionsArgs, m as BrandScoped, M as MembershipDetailArgs, R as ReservationDetailArgs, e as BookingHold, P as PaymentIntentInfo, o as CreateBookingArgs, n as CheckoutStatusResult } from './account-Cl6hElpL.cjs';
4
+
5
+ interface BowlosProviderProps {
6
+ /** A prebuilt client, or pass `config` to have one created and memoized. */
7
+ client?: BowlosClient;
8
+ config?: BowlosClientConfig;
9
+ children: ReactNode;
10
+ }
11
+ declare function BowlosProvider({ client, config, children }: BowlosProviderProps): react_jsx_runtime.JSX.Element;
12
+ declare function useBowlosClient(): BowlosClient;
13
+ type AccountStatus = "loading" | AuthState;
14
+ interface UseAccountResult {
15
+ status: AccountStatus;
16
+ customer: Customer | null;
17
+ error: BowlosApiError | null;
18
+ signIn: (email: string, password: string) => Promise<void>;
19
+ signUp: (email: string, password: string) => Promise<void>;
20
+ link: (profile: LinkProfile) => Promise<void>;
21
+ signOut: () => Promise<void>;
22
+ refresh: () => Promise<void>;
23
+ }
24
+ /** Customer session state + actions. Probes once on mount; each action
25
+ * re-probes so `status`/`customer` stay current. */
26
+ declare function useAccount(): UseAccountResult;
27
+ interface UseQueryOptions {
28
+ /** Send the customer bearer token (for session-scoped reads). */
29
+ auth?: boolean;
30
+ /** Skip fetching until true. Defaults to true. */
31
+ enabled?: boolean;
32
+ }
33
+ interface UseQueryResult<T> {
34
+ data: T | null;
35
+ error: BowlosApiError | null;
36
+ loading: boolean;
37
+ refetch: () => Promise<void>;
38
+ }
39
+ /** Generic read hook over a gateway route. The typed data hooks
40
+ * (`useAvailability`, etc.) will wrap this with route names + arg types. */
41
+ declare function useBowlosQuery<T = unknown>(name: string, args?: Record<string, unknown>, options?: UseQueryOptions): UseQueryResult<T>;
42
+
43
+ /**
44
+ * Typed React data hooks for the booking funnel, built on `useBowlosQuery`.
45
+ * Same arg/result types as the framework-agnostic functions in `data.ts`.
46
+ */
47
+
48
+ /** Live free-unit availability for a product / date / time window. */
49
+ declare function useAvailability(args: AvailabilityArgs, options?: UseQueryOptions): UseQueryResult<AvailabilityResult>;
50
+ /** Authoritative price quote for the chosen booking inputs. */
51
+ declare function useBookingPreview(args: BookingPreviewArgs, options?: UseQueryOptions): UseQueryResult<BookingQuote>;
52
+ /** The signed-in customer's reservations. */
53
+ declare function useMyReservations<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
54
+ /** One of the customer's reservations, by displayId. */
55
+ declare function useMyReservationDetail<T = unknown>(args: ReservationDetailArgs, options?: UseQueryOptions): UseQueryResult<T>;
56
+ /** The customer's memberships. */
57
+ declare function useMyMemberships<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
58
+ /** One membership's detail. */
59
+ declare function useMyMembershipDetail<T = unknown>(args: MembershipDetailArgs, options?: UseQueryOptions): UseQueryResult<T>;
60
+ /** Loyalty tier + points. */
61
+ declare function useMyLoyalty<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
62
+ /** Account credit balance + ledger. */
63
+ declare function useMyCredits<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
64
+ /** Issued wallet passes. */
65
+ declare function useMyPasses<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
66
+ /** The public flash-sale page (members see prices; anonymous gets the locked view). */
67
+ declare function useFlashSale<T = unknown>(args: FlashSaleArgs, options?: UseQueryOptions): UseQueryResult<T>;
68
+ /** Per-start-hour options for a flash-sale reservation item (members only). */
69
+ declare function useFlashSaleBookingOptions<T = unknown>(args: FlashBookingOptionsArgs, options?: UseQueryOptions): UseQueryResult<T>;
70
+
71
+ type BookingFlowStatus = "idle" | "holding" | "held" | "preparingPayment" | "awaitingPayment" | "confirmed" | "expired" | "failed" | "abandoned" | "error";
72
+ interface BookingReservationRef {
73
+ reservationId: string | null;
74
+ reservationDisplayId: string | null;
75
+ }
76
+ interface UseBookingFlowResult {
77
+ status: BookingFlowStatus;
78
+ hold: BookingHold | null;
79
+ refToken: string | null;
80
+ paymentIntent: PaymentIntentInfo | null;
81
+ reservation: BookingReservationRef | null;
82
+ requiresPayment: boolean | null;
83
+ error: BowlosApiError | null;
84
+ startHold: (args: CreateBookingArgs) => Promise<void>;
85
+ preparePayment: () => Promise<PaymentIntentInfo | null>;
86
+ pollStatus: () => Promise<CheckoutStatusResult | null>;
87
+ startPolling: (intervalMs?: number) => void;
88
+ stopPolling: () => void;
89
+ abandon: () => Promise<void>;
90
+ reset: () => void;
91
+ }
92
+ declare function useBookingFlow(): UseBookingFlowResult;
93
+
94
+ export { type AccountStatus, type BookingFlowStatus, type BookingReservationRef, BowlosProvider, type BowlosProviderProps, type UseAccountResult, type UseBookingFlowResult, type UseQueryOptions, type UseQueryResult, useAccount, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosQuery, useFlashSale, useFlashSaleBookingOptions, useMyCredits, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations };
@@ -0,0 +1,94 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { A as AuthState, j as BowlosClient, k as BowlosClientConfig, p as Customer, h as BowlosApiError, L as LinkProfile, a as AvailabilityArgs, b as AvailabilityResult, f as BookingPreviewArgs, g as BookingQuote, r as FlashSaleArgs, q as FlashBookingOptionsArgs, m as BrandScoped, M as MembershipDetailArgs, R as ReservationDetailArgs, e as BookingHold, P as PaymentIntentInfo, o as CreateBookingArgs, n as CheckoutStatusResult } from './account-Cl6hElpL.js';
4
+
5
+ interface BowlosProviderProps {
6
+ /** A prebuilt client, or pass `config` to have one created and memoized. */
7
+ client?: BowlosClient;
8
+ config?: BowlosClientConfig;
9
+ children: ReactNode;
10
+ }
11
+ declare function BowlosProvider({ client, config, children }: BowlosProviderProps): react_jsx_runtime.JSX.Element;
12
+ declare function useBowlosClient(): BowlosClient;
13
+ type AccountStatus = "loading" | AuthState;
14
+ interface UseAccountResult {
15
+ status: AccountStatus;
16
+ customer: Customer | null;
17
+ error: BowlosApiError | null;
18
+ signIn: (email: string, password: string) => Promise<void>;
19
+ signUp: (email: string, password: string) => Promise<void>;
20
+ link: (profile: LinkProfile) => Promise<void>;
21
+ signOut: () => Promise<void>;
22
+ refresh: () => Promise<void>;
23
+ }
24
+ /** Customer session state + actions. Probes once on mount; each action
25
+ * re-probes so `status`/`customer` stay current. */
26
+ declare function useAccount(): UseAccountResult;
27
+ interface UseQueryOptions {
28
+ /** Send the customer bearer token (for session-scoped reads). */
29
+ auth?: boolean;
30
+ /** Skip fetching until true. Defaults to true. */
31
+ enabled?: boolean;
32
+ }
33
+ interface UseQueryResult<T> {
34
+ data: T | null;
35
+ error: BowlosApiError | null;
36
+ loading: boolean;
37
+ refetch: () => Promise<void>;
38
+ }
39
+ /** Generic read hook over a gateway route. The typed data hooks
40
+ * (`useAvailability`, etc.) will wrap this with route names + arg types. */
41
+ declare function useBowlosQuery<T = unknown>(name: string, args?: Record<string, unknown>, options?: UseQueryOptions): UseQueryResult<T>;
42
+
43
+ /**
44
+ * Typed React data hooks for the booking funnel, built on `useBowlosQuery`.
45
+ * Same arg/result types as the framework-agnostic functions in `data.ts`.
46
+ */
47
+
48
+ /** Live free-unit availability for a product / date / time window. */
49
+ declare function useAvailability(args: AvailabilityArgs, options?: UseQueryOptions): UseQueryResult<AvailabilityResult>;
50
+ /** Authoritative price quote for the chosen booking inputs. */
51
+ declare function useBookingPreview(args: BookingPreviewArgs, options?: UseQueryOptions): UseQueryResult<BookingQuote>;
52
+ /** The signed-in customer's reservations. */
53
+ declare function useMyReservations<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
54
+ /** One of the customer's reservations, by displayId. */
55
+ declare function useMyReservationDetail<T = unknown>(args: ReservationDetailArgs, options?: UseQueryOptions): UseQueryResult<T>;
56
+ /** The customer's memberships. */
57
+ declare function useMyMemberships<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
58
+ /** One membership's detail. */
59
+ declare function useMyMembershipDetail<T = unknown>(args: MembershipDetailArgs, options?: UseQueryOptions): UseQueryResult<T>;
60
+ /** Loyalty tier + points. */
61
+ declare function useMyLoyalty<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
62
+ /** Account credit balance + ledger. */
63
+ declare function useMyCredits<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
64
+ /** Issued wallet passes. */
65
+ declare function useMyPasses<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
66
+ /** The public flash-sale page (members see prices; anonymous gets the locked view). */
67
+ declare function useFlashSale<T = unknown>(args: FlashSaleArgs, options?: UseQueryOptions): UseQueryResult<T>;
68
+ /** Per-start-hour options for a flash-sale reservation item (members only). */
69
+ declare function useFlashSaleBookingOptions<T = unknown>(args: FlashBookingOptionsArgs, options?: UseQueryOptions): UseQueryResult<T>;
70
+
71
+ type BookingFlowStatus = "idle" | "holding" | "held" | "preparingPayment" | "awaitingPayment" | "confirmed" | "expired" | "failed" | "abandoned" | "error";
72
+ interface BookingReservationRef {
73
+ reservationId: string | null;
74
+ reservationDisplayId: string | null;
75
+ }
76
+ interface UseBookingFlowResult {
77
+ status: BookingFlowStatus;
78
+ hold: BookingHold | null;
79
+ refToken: string | null;
80
+ paymentIntent: PaymentIntentInfo | null;
81
+ reservation: BookingReservationRef | null;
82
+ requiresPayment: boolean | null;
83
+ error: BowlosApiError | null;
84
+ startHold: (args: CreateBookingArgs) => Promise<void>;
85
+ preparePayment: () => Promise<PaymentIntentInfo | null>;
86
+ pollStatus: () => Promise<CheckoutStatusResult | null>;
87
+ startPolling: (intervalMs?: number) => void;
88
+ stopPolling: () => void;
89
+ abandon: () => Promise<void>;
90
+ reset: () => void;
91
+ }
92
+ declare function useBookingFlow(): UseBookingFlowResult;
93
+
94
+ export { type AccountStatus, type BookingFlowStatus, type BookingReservationRef, BowlosProvider, type BowlosProviderProps, type UseAccountResult, type UseBookingFlowResult, type UseQueryOptions, type UseQueryResult, useAccount, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosQuery, useFlashSale, useFlashSaleBookingOptions, useMyCredits, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations };
package/dist/react.js ADDED
@@ -0,0 +1,299 @@
1
+ import { createBooking, createCheckoutPaymentIntent, getCheckoutStatus, abandonCheckout } from './chunk-TZTFJVDI.js';
2
+ import { createBowlosClient, BowlosApiError, BOWLOS_ERROR_CODES } from './chunk-TCYTNCUL.js';
3
+ import { createContext, useRef, useContext, useState, useCallback, useEffect } from 'react';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ var BowlosContext = createContext(null);
7
+ function BowlosProvider({ client, config, children }) {
8
+ const ref = useRef(client ?? null);
9
+ if (!ref.current) {
10
+ if (!config) {
11
+ throw new Error("BowlosProvider requires either a `client` or a `config`.");
12
+ }
13
+ ref.current = createBowlosClient(config);
14
+ }
15
+ return /* @__PURE__ */ jsx(BowlosContext.Provider, { value: ref.current, children });
16
+ }
17
+ function useBowlosClient() {
18
+ const client = useContext(BowlosContext);
19
+ if (!client) {
20
+ throw new Error("useBowlosClient must be used within a <BowlosProvider>.");
21
+ }
22
+ return client;
23
+ }
24
+ function useAccount() {
25
+ const client = useBowlosClient();
26
+ const [status, setStatus] = useState("loading");
27
+ const [customer, setCustomer] = useState(null);
28
+ const [error, setError] = useState(null);
29
+ const refresh = useCallback(async () => {
30
+ try {
31
+ const state = await client.probe();
32
+ setStatus(state);
33
+ setCustomer(state === "linked" ? await client.me() : null);
34
+ setError(null);
35
+ } catch (e) {
36
+ setStatus("unauthenticated");
37
+ setCustomer(null);
38
+ if (e instanceof BowlosApiError) setError(e);
39
+ }
40
+ }, [client]);
41
+ useEffect(() => {
42
+ void refresh();
43
+ }, [refresh]);
44
+ const run = useCallback(
45
+ async (action) => {
46
+ setError(null);
47
+ try {
48
+ await action();
49
+ await refresh();
50
+ } catch (e) {
51
+ if (e instanceof BowlosApiError) setError(e);
52
+ throw e;
53
+ }
54
+ },
55
+ [refresh]
56
+ );
57
+ const signIn = useCallback(
58
+ (email, password) => run(() => client.signIn(email, password)),
59
+ [client, run]
60
+ );
61
+ const signUp = useCallback(
62
+ (email, password) => run(() => client.signUp(email, password)),
63
+ [client, run]
64
+ );
65
+ const link = useCallback((profile) => run(() => client.link(profile)), [client, run]);
66
+ const signOut = useCallback(() => run(() => client.signOut()), [client, run]);
67
+ return { status, customer, error, signIn, signUp, link, signOut, refresh };
68
+ }
69
+ function useBowlosQuery(name, args = {}, options = {}) {
70
+ const client = useBowlosClient();
71
+ const auth = options.auth ?? false;
72
+ const enabled = options.enabled ?? true;
73
+ const [data, setData] = useState(null);
74
+ const [error, setError] = useState(null);
75
+ const [loading, setLoading] = useState(enabled);
76
+ const argsKey = JSON.stringify(args);
77
+ const refetch = useCallback(async () => {
78
+ setLoading(true);
79
+ setError(null);
80
+ try {
81
+ const result = await client.call(name, JSON.parse(argsKey), {
82
+ auth
83
+ });
84
+ setData(result);
85
+ } catch (e) {
86
+ if (e instanceof BowlosApiError) setError(e);
87
+ setData(null);
88
+ } finally {
89
+ setLoading(false);
90
+ }
91
+ }, [client, name, argsKey, auth]);
92
+ useEffect(() => {
93
+ if (enabled) void refetch();
94
+ }, [enabled, refetch]);
95
+ return { data, error, loading, refetch };
96
+ }
97
+
98
+ // src/hooks.tsx
99
+ function useAvailability(args, options) {
100
+ return useBowlosQuery("checkAvailability", args, options);
101
+ }
102
+ function useBookingPreview(args, options) {
103
+ return useBowlosQuery("bookingPreview", args, options);
104
+ }
105
+ function useMyReservations(args, options) {
106
+ return useBowlosQuery("listMyReservations", args, { ...options, auth: true });
107
+ }
108
+ function useMyReservationDetail(args, options) {
109
+ return useBowlosQuery("getMyReservationDetail", args, { ...options, auth: true });
110
+ }
111
+ function useMyMemberships(args, options) {
112
+ return useBowlosQuery("listMyMemberships", args, { ...options, auth: true });
113
+ }
114
+ function useMyMembershipDetail(args, options) {
115
+ return useBowlosQuery("getMyMembershipDetail", args, { ...options, auth: true });
116
+ }
117
+ function useMyLoyalty(args, options) {
118
+ return useBowlosQuery("getMyLoyalty", args, { ...options, auth: true });
119
+ }
120
+ function useMyCredits(args, options) {
121
+ return useBowlosQuery("listMyCredits", args, { ...options, auth: true });
122
+ }
123
+ function useMyPasses(args, options) {
124
+ return useBowlosQuery("listMyPasses", args, { ...options, auth: true });
125
+ }
126
+ function useFlashSale(args, options) {
127
+ return useBowlosQuery("getPublicFlashSaleBySlug", args, { ...options, auth: true });
128
+ }
129
+ function useFlashSaleBookingOptions(args, options) {
130
+ return useBowlosQuery("getFlashSaleBookingOptions", args, { ...options, auth: true });
131
+ }
132
+ var DEFAULT_POLL_MS = 2500;
133
+ function useBookingFlow() {
134
+ const client = useBowlosClient();
135
+ const [status, setStatus] = useState("idle");
136
+ const [hold, setHold] = useState(null);
137
+ const [refToken, setRefToken] = useState(null);
138
+ const [paymentIntent, setPaymentIntent] = useState(null);
139
+ const [reservation, setReservation] = useState(null);
140
+ const [error, setError] = useState(null);
141
+ const refTokenRef = useRef(null);
142
+ const pollRef = useRef(null);
143
+ const stopPolling = useCallback(() => {
144
+ if (pollRef.current !== null) {
145
+ clearInterval(pollRef.current);
146
+ pollRef.current = null;
147
+ }
148
+ }, []);
149
+ useEffect(() => stopPolling, [stopPolling]);
150
+ const reset = useCallback(() => {
151
+ stopPolling();
152
+ refTokenRef.current = null;
153
+ setRefToken(null);
154
+ setHold(null);
155
+ setPaymentIntent(null);
156
+ setReservation(null);
157
+ setError(null);
158
+ setStatus("idle");
159
+ }, [stopPolling]);
160
+ const applyStatus = useCallback(
161
+ (s) => {
162
+ switch (s.status) {
163
+ case "paid_materialized":
164
+ setReservation({
165
+ reservationId: s.reservationId,
166
+ reservationDisplayId: s.reservationDisplayId
167
+ });
168
+ setStatus("confirmed");
169
+ stopPolling();
170
+ break;
171
+ case "expired":
172
+ setStatus("expired");
173
+ stopPolling();
174
+ break;
175
+ case "abandoned":
176
+ setStatus("abandoned");
177
+ stopPolling();
178
+ break;
179
+ case "payment_failed_retryable":
180
+ setStatus("failed");
181
+ stopPolling();
182
+ break;
183
+ case "not_found":
184
+ setError(new BowlosApiError(BOWLOS_ERROR_CODES.NOT_FOUND, "Checkout not found.", 404));
185
+ setStatus("error");
186
+ stopPolling();
187
+ break;
188
+ }
189
+ },
190
+ [stopPolling]
191
+ );
192
+ const startHold = useCallback(
193
+ async (args) => {
194
+ stopPolling();
195
+ setError(null);
196
+ setPaymentIntent(null);
197
+ setReservation(null);
198
+ setStatus("holding");
199
+ try {
200
+ const h = await createBooking(client, args);
201
+ setHold(h);
202
+ const rt = typeof h.checkoutRefToken === "string" ? h.checkoutRefToken : null;
203
+ refTokenRef.current = rt;
204
+ setRefToken(rt);
205
+ if (!h.requiresPayment) {
206
+ setReservation({
207
+ reservationId: h.reservationId ?? null,
208
+ reservationDisplayId: h.reservationDisplayId ?? null
209
+ });
210
+ setStatus("confirmed");
211
+ } else if (rt) {
212
+ setStatus("held");
213
+ } else {
214
+ setError(
215
+ new BowlosApiError(
216
+ "UNSUPPORTED_BOOKING_PATH",
217
+ "This booking requires payment but no checkout hold was returned.",
218
+ 0
219
+ )
220
+ );
221
+ setStatus("error");
222
+ }
223
+ } catch (e) {
224
+ if (e instanceof BowlosApiError) setError(e);
225
+ setStatus("error");
226
+ }
227
+ },
228
+ [client, stopPolling]
229
+ );
230
+ const preparePayment = useCallback(async () => {
231
+ const rt = refTokenRef.current;
232
+ if (!rt) return null;
233
+ setError(null);
234
+ setStatus("preparingPayment");
235
+ try {
236
+ const pi = await createCheckoutPaymentIntent(client, rt);
237
+ setPaymentIntent(pi);
238
+ setStatus("awaitingPayment");
239
+ return pi;
240
+ } catch (e) {
241
+ if (e instanceof BowlosApiError) setError(e);
242
+ setStatus("error");
243
+ return null;
244
+ }
245
+ }, [client]);
246
+ const pollStatus = useCallback(async () => {
247
+ const rt = refTokenRef.current;
248
+ if (!rt) return null;
249
+ try {
250
+ const s = await getCheckoutStatus(client, rt);
251
+ applyStatus(s);
252
+ return s;
253
+ } catch (e) {
254
+ if (e instanceof BowlosApiError) setError(e);
255
+ return null;
256
+ }
257
+ }, [client, applyStatus]);
258
+ const startPolling = useCallback(
259
+ (intervalMs = DEFAULT_POLL_MS) => {
260
+ stopPolling();
261
+ void pollStatus();
262
+ pollRef.current = setInterval(() => {
263
+ void pollStatus();
264
+ }, intervalMs);
265
+ },
266
+ [pollStatus, stopPolling]
267
+ );
268
+ const abandon = useCallback(async () => {
269
+ stopPolling();
270
+ const rt = refTokenRef.current;
271
+ if (rt) {
272
+ try {
273
+ await abandonCheckout(client, rt);
274
+ } catch {
275
+ }
276
+ }
277
+ setStatus("abandoned");
278
+ }, [client, stopPolling]);
279
+ return {
280
+ status,
281
+ hold,
282
+ refToken,
283
+ paymentIntent,
284
+ reservation,
285
+ requiresPayment: hold ? hold.requiresPayment : null,
286
+ error,
287
+ startHold,
288
+ preparePayment,
289
+ pollStatus,
290
+ startPolling,
291
+ stopPolling,
292
+ abandon,
293
+ reset
294
+ };
295
+ }
296
+
297
+ export { BowlosProvider, useAccount, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosQuery, useFlashSale, useFlashSaleBookingOptions, useMyCredits, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations };
298
+ //# sourceMappingURL=react.js.map
299
+ //# sourceMappingURL=react.js.map