@bowlos/reservations 0.22.1 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/doctor.ts","../src/account.ts","../src/catalog.ts"],"names":[],"mappings":";;;;AA0DA,IAAM,cAAA,GAAiB,gBAAA;AAIvB,eAAsB,UAAU,OAAA,EAA+C;AAC7E,EAAA,MAAM,SAAwB,EAAC;AAC/B,EAAA,MAAM,SAAuB,EAAE,EAAA,EAAI,MAAM,MAAA,EAAQ,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAG1E,EAAA,MAAM,eAAyB,EAAC;AAChC,EAAA,IAAI,CAAC,OAAA,CAAQ,MAAA,EAAQ,YAAA,CAAa,KAAK,mBAAmB,CAAA;AAC1D,EAAA,IAAI,SAAA,GAAwB,IAAA;AAC5B,EAAA,IAAI;AACF,IAAA,SAAA,GAAY,IAAI,GAAA,CAAI,OAAA,CAAQ,OAAO,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AACN,IAAA,YAAA,CAAa,KAAK,8BAA8B,CAAA;AAAA,EAClD;AACA,EAAA,IAAI,YAAA,CAAa,SAAS,CAAA,EAAG;AAC3B,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,EAAA,EAAI,QAAA;AAAA,MACJ,KAAA,EAAO,sBAAA;AAAA,MACP,MAAA,EAAQ,MAAA;AAAA,MACR,MAAA,EAAQ,CAAA,EAAG,YAAA,CAAa,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,CAAA;AAAA,MAClC,GAAA,EAAK;AAAA,KACN,CAAA;AACD,IAAA,MAAA,CAAO,EAAA,GAAK,KAAA;AACZ,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,WAAA,GACJ,SAAA,KAAc,IAAA,IAAQ,CAAC,SAAA,CAAU,QAAA,CAAS,OAAA,CAAQ,MAAA,EAAQ,EA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A,CAAQ,kBAAA,EAAoB,IAAI,CAAA;AAChD;AAKO,SAAS,cAAA,CAA4B,QAAsB,IAAA,EAAmC;AACnG,EAAA,OAAO,MAAA,CAAO,IAAA,CAAQ,iCAAA,EAAmC,IAAI,CAAA;AAC/D;AAGO,SAAS,qBAAA,CACd,QACA,IAAA,EACY;AACZ,EAAA,OAAO,MAAA,CAAO,IAAA,CAAQ,uBAAA,EAAyB,IAAI,CAAA;AACrD;AAGO,SAAS,aAAA,CAA2B,QAAsB,IAAA,EAAoC;AACnG,EAAA,OAAO,MAAA,CAAO,IAAA,CAAQ,qBAAA,EAAuB,IAAI,CAAA;AACnD","file":"index.js","sourcesContent":["/**\n * `runDoctor` — a setup-readiness oracle for a site built on @bowlos/reservations.\n *\n * It runs a short sequence of checks against a configured gateway + API key and\n * returns a structured report (pass / warn / fail / skip), each with a one-line\n * fix when it isn't a pass. The point is to make per-site setup self-debuggable\n * — it walks the failure modes a new center site actually hits, in order:\n * config → gateway reachable → API key valid → origin allow-listed → data plane.\n *\n * Framework-agnostic and dependency-free: it builds a `BowlosClient`, leans on\n * `client.ping()` (one call covers reachability + key + origin + rate-limit),\n * and reports honestly — checks it can't run from the current environment are\n * `skip`ped with guidance rather than faked. The `bowlos doctor` CLI is a thin\n * wrapper that pretty-prints the report.\n */\nimport { createBowlosClient } from \"./client\";\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport type { FetchLike, PingResult } from \"./types\";\n\nexport type DoctorCheckStatus = \"pass\" | \"warn\" | \"fail\" | \"skip\";\n\nexport interface DoctorCheck {\n /** Stable id (`config` | `gateway` | `api-key` | `origin` | `rate-limit` | `data-read` | `payments`). */\n id: string;\n title: string;\n status: DoctorCheckStatus;\n detail: string;\n /** One-line remediation, present when `status` isn't `pass`. */\n fix?: string;\n}\n\nexport interface DoctorReport {\n /** True when no check failed (warnings and skips are tolerated). */\n ok: boolean;\n checks: DoctorCheck[];\n /** Echoed back so the CLI can show what it probed. */\n baseUrl: string;\n /** From a successful ping — the key's brand + mode. */\n brandId?: string;\n mode?: \"live\" | \"test\";\n}\n\nexport interface DoctorOptions {\n apiKey: string;\n baseUrl: string;\n /**\n * The deployed site origin. Origin allow-listing is enforced by the gateway\n * only for browser requests (Origin is a forbidden header from Node), so this\n * can be actively verified only in a browser; from Node it informs the\n * skip-guidance message.\n */\n origin?: string;\n /** Skip the (anonymous) data-plane read even when a brand is known. */\n skipDataRead?: boolean;\n /** Injectable transport (tests / SSR polyfills). */\n fetch?: FetchLike;\n}\n\nconst GATEWAY_SUFFIX = \"/api/public/v1\";\n\n/** Run the readiness checks and return a structured report. Never throws — every\n * failure mode is captured as a check. */\nexport async function runDoctor(options: DoctorOptions): Promise<DoctorReport> {\n const checks: DoctorCheck[] = [];\n const report: DoctorReport = { ok: true, checks, baseUrl: options.baseUrl };\n\n // 1) config — can we even build a client?\n const configIssues: string[] = [];\n if (!options.apiKey) configIssues.push(\"`apiKey` is empty\");\n let parsedUrl: URL | null = null;\n try {\n parsedUrl = new URL(options.baseUrl);\n } catch {\n configIssues.push(\"`baseUrl` is not a valid URL\");\n }\n if (configIssues.length > 0) {\n checks.push({\n id: \"config\",\n title: \"Client configuration\",\n status: \"fail\",\n detail: `${configIssues.join(\"; \")}.`,\n fix: \"Pass a brand API key and the gateway base URL, e.g. https://<deployment>.convex.site/api/public/v1\",\n });\n report.ok = false;\n return report; // can't probe without a valid client config\n }\n\n const urlMisaimed =\n parsedUrl !== null && !parsedUrl.pathname.replace(/\\/+$/, \"\").endsWith(GATEWAY_SUFFIX);\n checks.push({\n id: \"config\",\n title: \"Client configuration\",\n status: urlMisaimed ? \"warn\" : \"pass\",\n detail: urlMisaimed\n ? `baseUrl \"${options.baseUrl}\" doesn't end with ${GATEWAY_SUFFIX} — it should point at the gateway, not the site root.`\n : \"API key present; base URL well-formed.\",\n fix: urlMisaimed ? `Use the gateway URL, e.g. ${parsedUrl?.origin}${GATEWAY_SUFFIX}` : undefined,\n });\n\n const client = createBowlosClient({\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n fetch: options.fetch,\n });\n\n // 2) one ping covers: gateway reachable + key valid + (browser) origin + rate-limit.\n let ping: PingResult | null = null;\n try {\n ping = await client.ping();\n report.brandId = ping.brandId;\n report.mode = ping.mode;\n checks.push({\n id: \"gateway\",\n title: \"Gateway reachable\",\n status: \"pass\",\n detail: `Reached ${options.baseUrl} (service \"${ping.service}\", ${ping.version}).`,\n });\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"pass\",\n detail: `Key valid for brand ${ping.brandId} — mode: ${ping.mode}.`,\n });\n } catch (e) {\n const err = e instanceof BowlosApiError ? e : null;\n const code = err?.code ?? BOWLOS_ERROR_CODES.UNKNOWN;\n // A network error (status 0) or a router 404 means no real gateway answered;\n // any other coded envelope means the gateway responded (and judged the key).\n const reached =\n err !== null && err.status !== 0 && code !== BOWLOS_ERROR_CODES.NETWORK_ERROR && code !== BOWLOS_ERROR_CODES.NOT_FOUND;\n\n checks.push({\n id: \"gateway\",\n title: \"Gateway reachable\",\n status: reached ? \"pass\" : \"fail\",\n detail: reached\n ? `Reached ${options.baseUrl}.`\n : code === BOWLOS_ERROR_CODES.NETWORK_ERROR\n ? `Could not reach ${options.baseUrl} (network error).`\n : `No public-API gateway responded at ${options.baseUrl}.`,\n fix: reached\n ? undefined\n : \"Check the base URL, that the Convex deployment is live, and that the public-API routes are deployed.\",\n });\n\n if (code === BOWLOS_ERROR_CODES.RATE_LIMITED) {\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"pass\",\n detail: \"Key accepted (this probe was rate-limited).\",\n });\n checks.push({\n id: \"rate-limit\",\n title: \"Rate-limit headroom\",\n status: \"warn\",\n detail: `Currently rate-limited${err?.retryAfterSeconds ? ` — retry after ${err.retryAfterSeconds}s` : \"\"}.`,\n fix: \"Back off and retry; raise the key's per-minute limit if your real traffic is higher.\",\n });\n } else if (code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED) {\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"pass\",\n detail: \"Key accepted; the request was blocked on origin.\",\n });\n checks.push({\n id: \"origin\",\n title: \"Origin allow-listed\",\n status: \"fail\",\n detail: \"The request origin is not on the key's allow-list.\",\n fix: `Add your site origin${options.origin ? ` (${options.origin})` : \"\"} to the API key's allowed origins.`,\n });\n } else if (reached) {\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"fail\",\n detail:\n code === BOWLOS_ERROR_CODES.API_KEY_INVALID || code === BOWLOS_ERROR_CODES.API_KEY_MISSING\n ? \"The gateway rejected the API key.\"\n : `The gateway returned ${code}.`,\n fix: \"Mint or rotate a brand API key in the operator admin (Super-Admin → API keys) and use that value.\",\n });\n } else {\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"skip\",\n detail: \"Skipped — the gateway wasn't reachable.\",\n });\n }\n }\n\n // 3) origin — only actively verifiable in a browser (Origin is a forbidden\n // header from Node). A successful ping in a browser means the current\n // origin IS allow-listed; otherwise skip with guidance.\n if (!checks.some((c) => c.id === \"origin\")) {\n const browserOrigin =\n typeof window !== \"undefined\" && typeof window.location?.origin === \"string\"\n ? window.location.origin\n : null;\n if (ping !== null && browserOrigin !== null) {\n checks.push({\n id: \"origin\",\n title: \"Origin allow-listed\",\n status: \"pass\",\n detail: `This origin (${browserOrigin}) is allow-listed for the key.`,\n });\n } else {\n checks.push({\n id: \"origin\",\n title: \"Origin allow-listed\",\n status: \"skip\",\n detail: \"Origin allow-listing is enforced only for browser requests, so it can't be verified from a CLI.\",\n fix: `Ensure your deployed site origin${options.origin ? ` (${options.origin})` : \"\"} is on the key's allowed-origins list; load the site and watch for ORIGIN_NOT_ALLOWED.`,\n });\n }\n }\n\n // 4) data plane — a cheap anonymous read proves gateway → manifest → query → scope.\n if (ping !== null && options.skipDataRead !== true) {\n try {\n const data = await client.call<unknown>(\"listPublicCenters\", { brandId: ping.brandId });\n const innerError = typeof data === \"object\" && data !== null && (data as { ok?: boolean }).ok === false;\n checks.push({\n id: \"data-read\",\n title: \"Data passthrough\",\n status: innerError ? \"warn\" : \"pass\",\n detail: innerError\n ? \"Reached the data plane, but listPublicCenters returned an error envelope.\"\n : \"Anonymous read (listPublicCenters) succeeded — gateway → query passthrough works.\",\n fix: innerError ? \"Confirm the brand has at least one published center.\" : undefined,\n });\n } catch (e) {\n const err = e instanceof BowlosApiError ? e : null;\n checks.push({\n id: \"data-read\",\n title: \"Data passthrough\",\n status: \"warn\",\n detail: `An anonymous read failed${err ? ` (${err.code})` : \"\"}.`,\n fix: \"Key + gateway are fine; this read may need a published center or differ by brand. Safe to ignore if your booking reads work.\",\n });\n }\n } else if (ping === null) {\n checks.push({\n id: \"data-read\",\n title: \"Data passthrough\",\n status: \"skip\",\n detail: \"Skipped — needs a reachable gateway.\",\n });\n }\n\n // 5) payments — Stripe Connect status isn't exposed over the public API yet.\n // Honest skip (no faked pass) so the operator knows to verify it elsewhere.\n checks.push({\n id: \"payments\",\n title: \"Payments connected\",\n status: \"skip\",\n detail: \"Stripe Connect status isn't exposed over the public API yet, so the doctor can't verify it here.\",\n fix: \"Confirm the operator's Stripe account is connected + charges-enabled in the admin (Payments → Connect).\",\n });\n\n report.ok = !checks.some((c) => c.status === \"fail\");\n return report;\n}\n","/**\n * Typed account + flash reads for @bowlos/reservations.\n *\n * Session-scoped account reads (require a signed-in customer) and the\n * session-aware flash-sale reads. Args are typed precisely — every account read\n * is brand-scoped. Results are generic (`<T = unknown>`): parameterize with your\n * own shape, or read `unknown` and narrow. (The backend return shapes are rich\n * and evolving; the SDK doesn't pin them here.) Each read has a framework-agnostic\n * function here and a React hook in `hooks.tsx`.\n */\nimport type { BowlosClient } from \"./client\";\n\n/** Every account read is scoped to the customer's Brand. */\nexport type BrandScoped = { brandId: string };\nexport type ReservationDetailArgs = { brandId: string; displayId: string };\nexport type EventOrderDetailArgs = { brandId: string; orderId: string };\nexport type MembershipDetailArgs = { brandId: string; membershipId: string };\nexport type FlashSaleArgs = { slug: string };\nexport type FlashBookingOptionsArgs = { slug: string; itemId: string };\nexport type FlashSalesArgs = { brandId: string };\n\n// ── account (require a signed-in customer) ───────────────────────────────────\n\nexport function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyReservations\", args, { auth: true });\n}\n\nexport function getMyReservationDetail<T = unknown>(\n client: BowlosClient,\n args: ReservationDetailArgs,\n): Promise<T> {\n return client.call<T>(\"getMyReservationDetail\", args, { auth: true });\n}\n\nexport function getMyEventOrders<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyEventOrders\", args, { auth: true });\n}\n\nexport function getMyEventOrder<T = unknown>(\n client: BowlosClient,\n args: EventOrderDetailArgs,\n): Promise<T> {\n return client.call<T>(\"getMyEventOrder\", args, { auth: true });\n}\n\nexport function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyMemberships\", args, { auth: true });\n}\n\nexport function getMyMembershipDetail<T = unknown>(\n client: BowlosClient,\n args: MembershipDetailArgs,\n): Promise<T> {\n return client.call<T>(\"getMyMembershipDetail\", args, { auth: true });\n}\n\nexport function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"getMyLoyalty\", args, { auth: true });\n}\n\nexport function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyCredits\", args, { auth: true });\n}\n\nexport function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyPasses\", args, { auth: true });\n}\n\n// ── flash sales (session-aware: members see prices) ──────────────────────────\n\nexport function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T> {\n return client.call<T>(\"getPublicFlashSaleBySlug\", args, { auth: true });\n}\n\n/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */\nexport function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T> {\n return client.call<T>(\"listPublicFlashSales\", args);\n}\n\nexport function getFlashSaleBookingOptions<T = unknown>(\n client: BowlosClient,\n args: FlashBookingOptionsArgs,\n): Promise<T> {\n return client.call<T>(\"getFlashSaleBookingOptions\", args, { auth: true });\n}\n\nexport type CreateFlashSaleBookingArgs = {\n slug: string;\n itemId: string;\n dateISO: string;\n startMinuteOfDay: number;\n durationMinutes: number;\n units: number;\n /** Per-attempt key; replays return the original checkout. */\n idempotencyKey: string;\n};\n\nexport interface FlashSaleBookingResult {\n /** Handle for the rest of the checkout: mint the PaymentIntent with\n * `createCheckoutPaymentIntent(client, { refToken })`, then poll\n * `getCheckoutStatus(client, refToken)` to materialization. */\n refToken: string;\n /** The SALE-priced total the PaymentIntent charges (base at the flash\n * price + tax + the Center fee). */\n amountDueCents: number;\n holdExpiresAt: number;\n breakdown: {\n baseSubtotalCents: number;\n reservationFeeCents: number;\n reservationFeeLabel: string | null;\n taxAddedCents: number;\n taxIncludedCents: number;\n totalCents: number;\n };\n}\n\n/**\n * v0.22.1 — book a flash-sale reservation item at its SALE price (the flash\n * analog of `eventOfferSlug`: the server binds the item's sale price, holds\n * the inventory, and opens a checkout). Signed-in customers only. Pick the\n * date/time from `getFlashSaleBookingOptions` — the purpose-built option\n * list — never the regular booking calendar.\n */\nexport function createFlashSaleBooking(\n client: BowlosClient,\n args: CreateFlashSaleBookingArgs,\n): Promise<FlashSaleBookingResult> {\n return client.call<FlashSaleBookingResult>(\"createFlashSaleBooking\", args, {\n auth: true,\n });\n}\n","/**\n * Public catalog reads for @bowlos/reservations — the \"what can I book/buy here\"\n * surface that powers `<BookingCatalog>`. All anonymous (no customer login).\n * Products + events + memberships are Center-scoped; packages + game cards are\n * Brand-scoped (with an optional Center filter). Results are generic (`<T>`);\n * the component types the display fields it needs.\n */\nimport type { BowlosClient } from \"./client\";\n\nexport type CenterScoped = { centerId: string };\nexport type BrandCatalogArgs = { brandId: string; centerId?: string };\n\n// ── canonical catalog (listPublicCatalog) ─────────────────────────────────────\n// The one read that returns every category grouped + per-surface visibility\n// already applied. Prefer this over the per-category lists below when you want\n// the full, admin-controlled catalog for a surface. Types mirror the backend\n// wire shape (`@bowlos/shared` public-catalog).\n\n/** Which public surface is asking — the backend applies that surface's\n * per-category + per-offer visibility before returning. */\nexport type PublicSurface = \"sdk_custom_site\" | \"white_label_web\" | \"mobile_app\";\n\nexport type CatalogCategory =\n | \"bowling\"\n | \"other_attractions\"\n | \"events\"\n | \"packages\"\n | \"memberships\"\n | \"game_passes\";\n\nexport type CatalogActionType =\n | \"book_reservation\"\n | \"view_event\"\n | \"buy_ticket\"\n | \"buy_package\"\n | \"buy_membership\"\n | \"buy_game_pass\";\n\nexport type CatalogSourceTable =\n | \"products\"\n | \"event_offers\"\n | \"packages\"\n | \"membership_templates\"\n | \"game_card_templates\";\n\n/** A normalized, surface-agnostic catalog item. Route by `action.type`, using\n * the IDs in `action.payload` (e.g. `productId`, `slug`, `packageId`,\n * `templateId`). `priceLabel` is an indicative \"from $X\" only (null for\n * products — show \"See times & pricing\"); the binding price comes from the\n * per-category preview after login. */\nexport interface CatalogItem {\n id: string;\n category: CatalogCategory;\n sourceTable: CatalogSourceTable;\n sourceId: string;\n title: string;\n subtitle?: string | null;\n description?: string | null;\n priceLabel?: string | null;\n imageUrl?: string | null;\n badgeLabel?: string | null;\n action: { type: CatalogActionType; payload: Record<string, string> };\n}\n\nexport interface CatalogSection {\n key: CatalogCategory;\n label: string;\n items: CatalogItem[];\n}\n\nexport interface CatalogResult {\n sections: CatalogSection[];\n}\n\n/** Args for the canonical catalog read. `surface` selects which visibility\n * rules the backend applies. */\nexport type CatalogArgs = {\n brandId: string;\n centerId: string;\n surface: PublicSurface;\n};\n\n/**\n * The canonical public catalog for a surface — every active, public,\n * bookable/sellable item grouped into the six first-class categories, with the\n * Center admin's per-surface category + offer visibility already applied.\n * Anonymous. This is the recommended way to list \"everything bookable here\":\n * one call, all categories, visibility-aware, consistent with the white-label\n * web + mobile surfaces.\n */\nexport function listCatalog<T = CatalogResult>(\n client: BowlosClient,\n args: CatalogArgs,\n): Promise<T> {\n return client.call<T>(\"listPublicCatalog\", args);\n}\n/** One package's full detail. `shareToken` reveals a hidden/unlisted package. */\nexport type PackageDetailArgs = { packageId: string; shareToken?: string };\n/** Args for a Center's operating-hours window on a date, across attraction types. */\nexport type CenterHoursArgs = { centerId: string; attractionTypeKeys: string[]; dateISO: string };\n\n/** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */\nexport function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T> {\n return client.call<T>(\"listPublicProducts\", args);\n}\n\n/** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */\nexport function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T> {\n return client.call<T>(\"listPublicEvents\", args);\n}\n\n/** Sellable event offers at a Center. These are the public lineup + event\n * landing-page records; use this instead of `listEvents` when routing a\n * customer to an event purchase flow. */\nexport function listEventOffers<T = unknown>(\n client: BowlosClient,\n args: CenterScoped,\n): Promise<T> {\n return client.call<T>(\"listPublicEventOffers\", args);\n}\n\n/** One sellable event offer by landing-page slug. */\nexport function getEventOffer<T = unknown>(\n client: BowlosClient,\n args: { slug: string },\n): Promise<T> {\n return client.call<T>(\"getPublicEventOffer\", args);\n}\n\n/** Purchasable packages at a Brand. */\nexport function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T> {\n return client.call<T>(\"listPublicPackages\", args);\n}\n\n/** Full detail for one package — components, optional add-ons, allowed start\n * times, duration, and quantity bounds. Drives the headless package config UI\n * (see HEADLESS.md → \"Buying a package\"). */\nexport function getPackage<T = unknown>(client: BowlosClient, args: PackageDetailArgs): Promise<T> {\n return client.call<T>(\"getPublicPackage\", args);\n}\n\n/** A Center's combined open/close window (minutes-from-midnight) for the given\n * attraction types on a date — the intersection across types; `null` if closed.\n * Bound a package's start times with its component attraction-type keys. */\nexport function getCenterHours<T = unknown>(client: BowlosClient, args: CenterHoursArgs): Promise<T> {\n return client.call<T>(\"getCenterOperatingHoursForTypes\", args);\n}\n\n/** Purchasable memberships at a Center. */\nexport function listPublicMemberships<T = unknown>(\n client: BowlosClient,\n args: CenterScoped,\n): Promise<T> {\n return client.call<T>(\"listPublicMemberships\", args);\n}\n\n/** Purchasable game cards / passes at a Brand. */\nexport function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T> {\n return client.call<T>(\"listPublicGameCards\", args);\n}\n"]}
1
+ {"version":3,"sources":["../src/doctor.ts","../src/account.ts","../src/catalog.ts"],"names":[],"mappings":";;;;AA0DA,IAAM,cAAA,GAAiB,gBAAA;AAIvB,eAAsB,UAAU,OAAA,EAA+C;AAC7E,EAAA,MAAM,SAAwB,EAAC;AAC/B,EAAA,MAAM,SAAuB,EAAE,EAAA,EAAI,MAAM,MAAA,EAAQ,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAG1E,EAAA,MAAM,eAAyB,EAAC;AAChC,EAAA,IAAI,CAAC,OAAA,CAAQ,MAAA,EAAQ,YAAA,CAAa,KAAK,mBAAmB,CAAA;AAC1D,EAAA,IAAI,SAAA,GAAwB,IAAA;AAC5B,EAAA,IAAI;AACF,IAAA,SAAA,GAAY,IAAI,GAAA,CAAI,OAAA,CAAQ,OAAO,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AACN,IAAA,YAAA,CAAa,KAAK,8BAA8B,CAAA;AAAA,EAClD;AACA,EAAA,IAAI,YAAA,CAAa,SAAS,CAAA,EAAG;AAC3B,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,EAAA,EAAI,QAAA;AAAA,MACJ,KAAA,EAAO,sBAAA;AAAA,MACP,MAAA,EAAQ,MAAA;AAAA,MACR,MAAA,EAAQ,CAAA,EAAG,YAAA,CAAa,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,CAAA;AAAA,MAClC,GAAA,EAAK;AAAA,KACN,CAAA;AACD,I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,EAAA,OAAO,MAAA,CAAO,IAAA,CAAQ,oBAAA,EAAsB,IAAI,CAAA;AAClD;AAKO,SAAS,UAAA,CAAwB,QAAsB,IAAA,EAAqC;AACjG,EAAA,OAAO,MAAA,CAAO,IAAA,CAAQ,kBAAA,EAAoB,IAAI,CAAA;AAChD;AAKO,SAAS,cAAA,CAA4B,QAAsB,IAAA,EAAmC;AACnG,EAAA,OAAO,MAAA,CAAO,IAAA,CAAQ,iCAAA,EAAmC,IAAI,CAAA;AAC/D;AAGO,SAAS,qBAAA,CACd,QACA,IAAA,EACY;AACZ,EAAA,OAAO,MAAA,CAAO,IAAA,CAAQ,uBAAA,EAAyB,IAAI,CAAA;AACrD;AAGO,SAAS,aAAA,CAA2B,QAAsB,IAAA,EAAoC;AACnG,EAAA,OAAO,MAAA,CAAO,IAAA,CAAQ,qBAAA,EAAuB,IAAI,CAAA;AACnD","file":"index.js","sourcesContent":["/**\n * `runDoctor` — a setup-readiness oracle for a site built on @bowlos/reservations.\n *\n * It runs a short sequence of checks against a configured gateway + API key and\n * returns a structured report (pass / warn / fail / skip), each with a one-line\n * fix when it isn't a pass. The point is to make per-site setup self-debuggable\n * — it walks the failure modes a new center site actually hits, in order:\n * config → gateway reachable → API key valid → origin allow-listed → data plane.\n *\n * Framework-agnostic and dependency-free: it builds a `BowlosClient`, leans on\n * `client.ping()` (one call covers reachability + key + origin + rate-limit),\n * and reports honestly — checks it can't run from the current environment are\n * `skip`ped with guidance rather than faked. The `bowlos doctor` CLI is a thin\n * wrapper that pretty-prints the report.\n */\nimport { createBowlosClient } from \"./client\";\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport type { FetchLike, PingResult } from \"./types\";\n\nexport type DoctorCheckStatus = \"pass\" | \"warn\" | \"fail\" | \"skip\";\n\nexport interface DoctorCheck {\n /** Stable id (`config` | `gateway` | `api-key` | `origin` | `rate-limit` | `data-read` | `payments`). */\n id: string;\n title: string;\n status: DoctorCheckStatus;\n detail: string;\n /** One-line remediation, present when `status` isn't `pass`. */\n fix?: string;\n}\n\nexport interface DoctorReport {\n /** True when no check failed (warnings and skips are tolerated). */\n ok: boolean;\n checks: DoctorCheck[];\n /** Echoed back so the CLI can show what it probed. */\n baseUrl: string;\n /** From a successful ping — the key's brand + mode. */\n brandId?: string;\n mode?: \"live\" | \"test\";\n}\n\nexport interface DoctorOptions {\n apiKey: string;\n baseUrl: string;\n /**\n * The deployed site origin. Origin allow-listing is enforced by the gateway\n * only for browser requests (Origin is a forbidden header from Node), so this\n * can be actively verified only in a browser; from Node it informs the\n * skip-guidance message.\n */\n origin?: string;\n /** Skip the (anonymous) data-plane read even when a brand is known. */\n skipDataRead?: boolean;\n /** Injectable transport (tests / SSR polyfills). */\n fetch?: FetchLike;\n}\n\nconst GATEWAY_SUFFIX = \"/api/public/v1\";\n\n/** Run the readiness checks and return a structured report. Never throws — every\n * failure mode is captured as a check. */\nexport async function runDoctor(options: DoctorOptions): Promise<DoctorReport> {\n const checks: DoctorCheck[] = [];\n const report: DoctorReport = { ok: true, checks, baseUrl: options.baseUrl };\n\n // 1) config — can we even build a client?\n const configIssues: string[] = [];\n if (!options.apiKey) configIssues.push(\"`apiKey` is empty\");\n let parsedUrl: URL | null = null;\n try {\n parsedUrl = new URL(options.baseUrl);\n } catch {\n configIssues.push(\"`baseUrl` is not a valid URL\");\n }\n if (configIssues.length > 0) {\n checks.push({\n id: \"config\",\n title: \"Client configuration\",\n status: \"fail\",\n detail: `${configIssues.join(\"; \")}.`,\n fix: \"Pass a brand API key and the gateway base URL, e.g. https://<deployment>.convex.site/api/public/v1\",\n });\n report.ok = false;\n return report; // can't probe without a valid client config\n }\n\n const urlMisaimed =\n parsedUrl !== null && !parsedUrl.pathname.replace(/\\/+$/, \"\").endsWith(GATEWAY_SUFFIX);\n checks.push({\n id: \"config\",\n title: \"Client configuration\",\n status: urlMisaimed ? \"warn\" : \"pass\",\n detail: urlMisaimed\n ? `baseUrl \"${options.baseUrl}\" doesn't end with ${GATEWAY_SUFFIX} — it should point at the gateway, not the site root.`\n : \"API key present; base URL well-formed.\",\n fix: urlMisaimed ? `Use the gateway URL, e.g. ${parsedUrl?.origin}${GATEWAY_SUFFIX}` : undefined,\n });\n\n const client = createBowlosClient({\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n fetch: options.fetch,\n });\n\n // 2) one ping covers: gateway reachable + key valid + (browser) origin + rate-limit.\n let ping: PingResult | null = null;\n try {\n ping = await client.ping();\n report.brandId = ping.brandId;\n report.mode = ping.mode;\n checks.push({\n id: \"gateway\",\n title: \"Gateway reachable\",\n status: \"pass\",\n detail: `Reached ${options.baseUrl} (service \"${ping.service}\", ${ping.version}).`,\n });\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"pass\",\n detail: `Key valid for brand ${ping.brandId} — mode: ${ping.mode}.`,\n });\n } catch (e) {\n const err = e instanceof BowlosApiError ? e : null;\n const code = err?.code ?? BOWLOS_ERROR_CODES.UNKNOWN;\n // A network error (status 0) or a router 404 means no real gateway answered;\n // any other coded envelope means the gateway responded (and judged the key).\n const reached =\n err !== null && err.status !== 0 && code !== BOWLOS_ERROR_CODES.NETWORK_ERROR && code !== BOWLOS_ERROR_CODES.NOT_FOUND;\n\n checks.push({\n id: \"gateway\",\n title: \"Gateway reachable\",\n status: reached ? \"pass\" : \"fail\",\n detail: reached\n ? `Reached ${options.baseUrl}.`\n : code === BOWLOS_ERROR_CODES.NETWORK_ERROR\n ? `Could not reach ${options.baseUrl} (network error).`\n : `No public-API gateway responded at ${options.baseUrl}.`,\n fix: reached\n ? undefined\n : \"Check the base URL, that the Convex deployment is live, and that the public-API routes are deployed.\",\n });\n\n if (code === BOWLOS_ERROR_CODES.RATE_LIMITED) {\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"pass\",\n detail: \"Key accepted (this probe was rate-limited).\",\n });\n checks.push({\n id: \"rate-limit\",\n title: \"Rate-limit headroom\",\n status: \"warn\",\n detail: `Currently rate-limited${err?.retryAfterSeconds ? ` — retry after ${err.retryAfterSeconds}s` : \"\"}.`,\n fix: \"Back off and retry; raise the key's per-minute limit if your real traffic is higher.\",\n });\n } else if (code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED) {\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"pass\",\n detail: \"Key accepted; the request was blocked on origin.\",\n });\n checks.push({\n id: \"origin\",\n title: \"Origin allow-listed\",\n status: \"fail\",\n detail: \"The request origin is not on the key's allow-list.\",\n fix: `Add your site origin${options.origin ? ` (${options.origin})` : \"\"} to the API key's allowed origins.`,\n });\n } else if (reached) {\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"fail\",\n detail:\n code === BOWLOS_ERROR_CODES.API_KEY_INVALID || code === BOWLOS_ERROR_CODES.API_KEY_MISSING\n ? \"The gateway rejected the API key.\"\n : `The gateway returned ${code}.`,\n fix: \"Mint or rotate a brand API key in the operator admin (Super-Admin → API keys) and use that value.\",\n });\n } else {\n checks.push({\n id: \"api-key\",\n title: \"API key accepted\",\n status: \"skip\",\n detail: \"Skipped — the gateway wasn't reachable.\",\n });\n }\n }\n\n // 3) origin — only actively verifiable in a browser (Origin is a forbidden\n // header from Node). A successful ping in a browser means the current\n // origin IS allow-listed; otherwise skip with guidance.\n if (!checks.some((c) => c.id === \"origin\")) {\n const browserOrigin =\n typeof window !== \"undefined\" && typeof window.location?.origin === \"string\"\n ? window.location.origin\n : null;\n if (ping !== null && browserOrigin !== null) {\n checks.push({\n id: \"origin\",\n title: \"Origin allow-listed\",\n status: \"pass\",\n detail: `This origin (${browserOrigin}) is allow-listed for the key.`,\n });\n } else {\n checks.push({\n id: \"origin\",\n title: \"Origin allow-listed\",\n status: \"skip\",\n detail: \"Origin allow-listing is enforced only for browser requests, so it can't be verified from a CLI.\",\n fix: `Ensure your deployed site origin${options.origin ? ` (${options.origin})` : \"\"} is on the key's allowed-origins list; load the site and watch for ORIGIN_NOT_ALLOWED.`,\n });\n }\n }\n\n // 4) data plane — a cheap anonymous read proves gateway → manifest → query → scope.\n if (ping !== null && options.skipDataRead !== true) {\n try {\n const data = await client.call<unknown>(\"listPublicCenters\", { brandId: ping.brandId });\n const innerError = typeof data === \"object\" && data !== null && (data as { ok?: boolean }).ok === false;\n checks.push({\n id: \"data-read\",\n title: \"Data passthrough\",\n status: innerError ? \"warn\" : \"pass\",\n detail: innerError\n ? \"Reached the data plane, but listPublicCenters returned an error envelope.\"\n : \"Anonymous read (listPublicCenters) succeeded — gateway → query passthrough works.\",\n fix: innerError ? \"Confirm the brand has at least one published center.\" : undefined,\n });\n } catch (e) {\n const err = e instanceof BowlosApiError ? e : null;\n checks.push({\n id: \"data-read\",\n title: \"Data passthrough\",\n status: \"warn\",\n detail: `An anonymous read failed${err ? ` (${err.code})` : \"\"}.`,\n fix: \"Key + gateway are fine; this read may need a published center or differ by brand. Safe to ignore if your booking reads work.\",\n });\n }\n } else if (ping === null) {\n checks.push({\n id: \"data-read\",\n title: \"Data passthrough\",\n status: \"skip\",\n detail: \"Skipped — needs a reachable gateway.\",\n });\n }\n\n // 5) payments — Stripe Connect status isn't exposed over the public API yet.\n // Honest skip (no faked pass) so the operator knows to verify it elsewhere.\n checks.push({\n id: \"payments\",\n title: \"Payments connected\",\n status: \"skip\",\n detail: \"Stripe Connect status isn't exposed over the public API yet, so the doctor can't verify it here.\",\n fix: \"Confirm the operator's Stripe account is connected + charges-enabled in the admin (Payments → Connect).\",\n });\n\n report.ok = !checks.some((c) => c.status === \"fail\");\n return report;\n}\n","/**\n * Typed account + flash reads for @bowlos/reservations.\n *\n * Session-scoped account reads (require a signed-in customer) and the\n * session-aware flash-sale reads. Args are typed precisely — every account read\n * is brand-scoped. Results are generic (`<T = unknown>`): parameterize with your\n * own shape, or read `unknown` and narrow. (The backend return shapes are rich\n * and evolving; the SDK doesn't pin them here.) Each read has a framework-agnostic\n * function here and a React hook in `hooks.tsx`.\n */\nimport type { BowlosClient } from \"./client\";\n\n/** Every account read is scoped to the customer's Brand. */\nexport type BrandScoped = { brandId: string };\nexport type ReservationDetailArgs = { brandId: string; displayId: string };\nexport type EventOrderDetailArgs = { brandId: string; orderId: string };\nexport type MembershipDetailArgs = { brandId: string; membershipId: string };\nexport type FlashSaleArgs = { slug: string };\nexport type FlashBookingOptionsArgs = { slug: string; itemId: string };\nexport type FlashSalesArgs = { brandId: string };\n\n// ── account (require a signed-in customer) ───────────────────────────────────\n\nexport function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyReservations\", args, { auth: true });\n}\n\nexport function getMyReservationDetail<T = unknown>(\n client: BowlosClient,\n args: ReservationDetailArgs,\n): Promise<T> {\n return client.call<T>(\"getMyReservationDetail\", args, { auth: true });\n}\n\nexport function getMyEventOrders<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyEventOrders\", args, { auth: true });\n}\n\nexport function getMyEventOrder<T = unknown>(\n client: BowlosClient,\n args: EventOrderDetailArgs,\n): Promise<T> {\n return client.call<T>(\"getMyEventOrder\", args, { auth: true });\n}\n\nexport function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyMemberships\", args, { auth: true });\n}\n\nexport function getMyMembershipDetail<T = unknown>(\n client: BowlosClient,\n args: MembershipDetailArgs,\n): Promise<T> {\n return client.call<T>(\"getMyMembershipDetail\", args, { auth: true });\n}\n\nexport function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"getMyLoyalty\", args, { auth: true });\n}\n\nexport function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyCredits\", args, { auth: true });\n}\n\nexport function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T> {\n return client.call<T>(\"listMyPasses\", args, { auth: true });\n}\n\nexport function getMyGameCards<T = MyGameCard[]>(\n client: BowlosClient,\n args: BrandScoped,\n): Promise<T> {\n return client.call<T>(\"listMyGameCards\", args, { auth: true });\n}\n\n// ── self-serve cancel (v0.23.0): preview + cancel for all four types ─────────\n//\n// Flow per type: preview(\"what you'll get back\") → confirm → cancel.\n// Money rule: store credit per the Center's cancellation policy; card refunds\n// are staff-only. Game cards are cancellable ONLY while fully unused (locked\n// rule) → full credit. The previewed amount is advisory (computed at view\n// time); the cancel re-computes authoritatively at confirm — re-preview right\n// before confirming if the page sat open. Cancel is safe to retry: a second\n// call on an already-cancelled item returns a NOT/​VALIDATION error (the credit\n// ledger dedupes, so no double credit), which the hooks surface as such.\n\n/** Outcome preview shared by all four cancel types. `bucket`/`hoursBeforeStart`/\n * `forfeitCents` are inert (null/0) for game cards (no time policy). */\nexport interface CancelPreview {\n cancellable: boolean;\n reason: string | null;\n bucket: string | null;\n hoursBeforeStart: number;\n creditCents: number;\n forfeitCents: number;\n paidCents: number;\n}\n\nexport interface CancelResult {\n id: string;\n status: string;\n creditCents: number;\n bucket?: string | null;\n hoursBeforeStart?: number;\n forfeitCents?: number;\n version?: number;\n}\n\nexport interface MyGameCard {\n id: string;\n displayId: string;\n cardName: string;\n status: \"active\" | \"depleted\" | \"expired\" | \"cancelled\" | \"refunded\";\n totalGames: number;\n remainingGames: number;\n shoesIncluded: boolean;\n purchasedAt: number;\n expiresAt: number;\n paidCents: number;\n /** Precomputed unused-only rule; the per-card preview is the source of truth. */\n cancellable: boolean;\n}\n\nexport type ReservationCancelArgs = {\n brandId: string;\n reservationId: string;\n expectedVersion: number;\n reason?: string;\n /** Per-attempt key; safe to retry. */\n idempotencyKey: string;\n};\nexport type OrderCancelArgs = {\n brandId: string;\n orderId: string;\n reason?: string;\n idempotencyKey: string;\n};\nexport type GameCardCancelArgs = {\n brandId: string;\n cardId: string;\n reason?: string;\n idempotencyKey: string;\n};\n\nexport function previewReservationCancellation<T = CancelPreview>(\n client: BowlosClient,\n args: { brandId: string; reservationId: string },\n): Promise<T> {\n return client.call<T>(\"previewMyCancellation\", args, { auth: true });\n}\nexport function previewEventOrderCancellation<T = CancelPreview>(\n client: BowlosClient,\n args: { brandId: string; orderId: string },\n): Promise<T> {\n return client.call<T>(\"previewMyEventOrderCancellation\", args, { auth: true });\n}\nexport function previewPackageOrderCancellation<T = CancelPreview>(\n client: BowlosClient,\n args: { brandId: string; orderId: string },\n): Promise<T> {\n return client.call<T>(\"previewMyPackageOrderCancellation\", args, { auth: true });\n}\nexport function previewGameCardCancellation<T = CancelPreview>(\n client: BowlosClient,\n args: { brandId: string; cardId: string },\n): Promise<T> {\n return client.call<T>(\"previewMyGameCardCancellation\", args, { auth: true });\n}\n\nexport function cancelMyReservation<T = CancelResult>(\n client: BowlosClient,\n args: ReservationCancelArgs,\n): Promise<T> {\n return client.call<T>(\"cancelMyReservation\", args, { auth: true });\n}\nexport function cancelMyEventOrder<T = CancelResult>(\n client: BowlosClient,\n args: OrderCancelArgs,\n): Promise<T> {\n return client.call<T>(\"cancelMyEventOrder\", args, { auth: true });\n}\nexport function cancelMyPackageOrder<T = CancelResult>(\n client: BowlosClient,\n args: OrderCancelArgs,\n): Promise<T> {\n return client.call<T>(\"cancelMyPackageOrder\", args, { auth: true });\n}\nexport function cancelMyGameCard<T = CancelResult>(\n client: BowlosClient,\n args: GameCardCancelArgs,\n): Promise<T> {\n return client.call<T>(\"cancelMyGameCard\", args, { auth: true });\n}\n\n// ── flash sales (session-aware: members see prices) ──────────────────────────\n\nexport function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T> {\n return client.call<T>(\"getPublicFlashSaleBySlug\", args, { auth: true });\n}\n\n/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */\nexport function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T> {\n return client.call<T>(\"listPublicFlashSales\", args);\n}\n\nexport function getFlashSaleBookingOptions<T = unknown>(\n client: BowlosClient,\n args: FlashBookingOptionsArgs,\n): Promise<T> {\n return client.call<T>(\"getFlashSaleBookingOptions\", args, { auth: true });\n}\n\nexport type CreateFlashSaleBookingArgs = {\n slug: string;\n itemId: string;\n dateISO: string;\n startMinuteOfDay: number;\n durationMinutes: number;\n units: number;\n /** Per-attempt key; replays return the original checkout. */\n idempotencyKey: string;\n};\n\nexport interface FlashSaleBookingResult {\n /** Handle for the rest of the checkout: mint the PaymentIntent with\n * `createCheckoutPaymentIntent(client, { refToken })`, then poll\n * `getCheckoutStatus(client, refToken)` to materialization. */\n refToken: string;\n /** The SALE-priced total the PaymentIntent charges (base at the flash\n * price + tax + the Center fee). */\n amountDueCents: number;\n holdExpiresAt: number;\n breakdown: {\n baseSubtotalCents: number;\n reservationFeeCents: number;\n reservationFeeLabel: string | null;\n taxAddedCents: number;\n taxIncludedCents: number;\n totalCents: number;\n };\n}\n\n/**\n * v0.22.1 — book a flash-sale reservation item at its SALE price (the flash\n * analog of `eventOfferSlug`: the server binds the item's sale price, holds\n * the inventory, and opens a checkout). Signed-in customers only. Pick the\n * date/time from `getFlashSaleBookingOptions` — the purpose-built option\n * list — never the regular booking calendar.\n */\nexport function createFlashSaleBooking(\n client: BowlosClient,\n args: CreateFlashSaleBookingArgs,\n): Promise<FlashSaleBookingResult> {\n return client.call<FlashSaleBookingResult>(\"createFlashSaleBooking\", args, {\n auth: true,\n });\n}\n","/**\n * Public catalog reads for @bowlos/reservations — the \"what can I book/buy here\"\n * surface that powers `<BookingCatalog>`. All anonymous (no customer login).\n * Products + events + memberships are Center-scoped; packages + game cards are\n * Brand-scoped (with an optional Center filter). Results are generic (`<T>`);\n * the component types the display fields it needs.\n */\nimport type { BowlosClient } from \"./client\";\n\nexport type CenterScoped = { centerId: string };\nexport type BrandCatalogArgs = { brandId: string; centerId?: string };\n\n// ── canonical catalog (listPublicCatalog) ─────────────────────────────────────\n// The one read that returns every category grouped + per-surface visibility\n// already applied. Prefer this over the per-category lists below when you want\n// the full, admin-controlled catalog for a surface. Types mirror the backend\n// wire shape (`@bowlos/shared` public-catalog).\n\n/** Which public surface is asking — the backend applies that surface's\n * per-category + per-offer visibility before returning. */\nexport type PublicSurface = \"sdk_custom_site\" | \"white_label_web\" | \"mobile_app\";\n\nexport type CatalogCategory =\n | \"bowling\"\n | \"other_attractions\"\n | \"events\"\n | \"packages\"\n | \"memberships\"\n | \"game_passes\";\n\nexport type CatalogActionType =\n | \"book_reservation\"\n | \"view_event\"\n | \"buy_ticket\"\n | \"buy_package\"\n | \"buy_membership\"\n | \"buy_game_pass\";\n\nexport type CatalogSourceTable =\n | \"products\"\n | \"event_offers\"\n | \"packages\"\n | \"membership_templates\"\n | \"game_card_templates\";\n\n/** A normalized, surface-agnostic catalog item. Route by `action.type`, using\n * the IDs in `action.payload` (e.g. `productId`, `slug`, `packageId`,\n * `templateId`). `priceLabel` is an indicative \"from $X\" only (null for\n * products — show \"See times & pricing\"); the binding price comes from the\n * per-category preview after login. */\nexport interface CatalogItem {\n id: string;\n category: CatalogCategory;\n sourceTable: CatalogSourceTable;\n sourceId: string;\n title: string;\n subtitle?: string | null;\n description?: string | null;\n priceLabel?: string | null;\n imageUrl?: string | null;\n badgeLabel?: string | null;\n action: { type: CatalogActionType; payload: Record<string, string> };\n}\n\nexport interface CatalogSection {\n key: CatalogCategory;\n label: string;\n items: CatalogItem[];\n}\n\nexport interface CatalogResult {\n sections: CatalogSection[];\n /**\n * Date-first booking (v0.24.0): the Center's default booking entry point.\n * Open your funnel on this; let the customer toggle to the other. Optional —\n * older gateways omit it (treat absent as `\"product_first\"`).\n */\n bookingEntryDefault?: \"product_first\" | \"date_first\";\n /** Center-local \"today\" (YYYY-MM-DD) — default + minimum for a date-first\n * date picker, so you don't guess the Center's timezone. Optional. */\n todayISO?: string;\n}\n\n/** Args for the canonical catalog read. `surface` selects which visibility\n * rules the backend applies. */\nexport type CatalogArgs = {\n brandId: string;\n centerId: string;\n surface: PublicSurface;\n};\n\n/**\n * The canonical public catalog for a surface — every active, public,\n * bookable/sellable item grouped into the six first-class categories, with the\n * Center admin's per-surface category + offer visibility already applied.\n * Anonymous. This is the recommended way to list \"everything bookable here\":\n * one call, all categories, visibility-aware, consistent with the white-label\n * web + mobile surfaces.\n */\nexport function listCatalog<T = CatalogResult>(\n client: BowlosClient,\n args: CatalogArgs,\n): Promise<T> {\n return client.call<T>(\"listPublicCatalog\", args);\n}\n/** One package's full detail. `shareToken` reveals a hidden/unlisted package. */\nexport type PackageDetailArgs = { packageId: string; shareToken?: string };\n/** Args for a Center's operating-hours window on a date, across attraction types. */\nexport type CenterHoursArgs = { centerId: string; attractionTypeKeys: string[]; dateISO: string };\n\n/** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */\nexport function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T> {\n return client.call<T>(\"listPublicProducts\", args);\n}\n\n/** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */\nexport function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T> {\n return client.call<T>(\"listPublicEvents\", args);\n}\n\n/** Sellable event offers at a Center. These are the public lineup + event\n * landing-page records; use this instead of `listEvents` when routing a\n * customer to an event purchase flow. */\nexport function listEventOffers<T = unknown>(\n client: BowlosClient,\n args: CenterScoped,\n): Promise<T> {\n return client.call<T>(\"listPublicEventOffers\", args);\n}\n\n/** One sellable event offer by landing-page slug. */\nexport function getEventOffer<T = unknown>(\n client: BowlosClient,\n args: { slug: string },\n): Promise<T> {\n return client.call<T>(\"getPublicEventOffer\", args);\n}\n\n/** Purchasable packages at a Brand. */\nexport function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T> {\n return client.call<T>(\"listPublicPackages\", args);\n}\n\n/** Full detail for one package — components, optional add-ons, allowed start\n * times, duration, and quantity bounds. Drives the headless package config UI\n * (see HEADLESS.md → \"Buying a package\"). */\nexport function getPackage<T = unknown>(client: BowlosClient, args: PackageDetailArgs): Promise<T> {\n return client.call<T>(\"getPublicPackage\", args);\n}\n\n/** A Center's combined open/close window (minutes-from-midnight) for the given\n * attraction types on a date — the intersection across types; `null` if closed.\n * Bound a package's start times with its component attraction-type keys. */\nexport function getCenterHours<T = unknown>(client: BowlosClient, args: CenterHoursArgs): Promise<T> {\n return client.call<T>(\"getCenterOperatingHoursForTypes\", args);\n}\n\n/** Purchasable memberships at a Center. */\nexport function listPublicMemberships<T = unknown>(\n client: BowlosClient,\n args: CenterScoped,\n): Promise<T> {\n return client.call<T>(\"listPublicMemberships\", args);\n}\n\n/** Purchasable game cards / passes at a Brand. */\nexport function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T> {\n return client.call<T>(\"listPublicGameCards\", args);\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
  import { A as AuthState, g as BowlosClient, h as BowlosClientConfig, l as Customer, L as LinkProfile } from './data-BKlgn8Ln.cjs';
4
- import { a as BowlosApiError } from './catalog-D1VoVaNe.cjs';
4
+ import { a as BowlosApiError } from './catalog-I7Lpar3V.cjs';
5
5
 
6
6
  interface BowlosProviderProps {
7
7
  /** A prebuilt client, or pass `config` to have one created and memoized. */
@@ -43,5 +43,18 @@ interface UseQueryResult<T> {
43
43
  /** Generic read hook over a gateway route. The typed data hooks
44
44
  * (`useAvailability`, etc.) will wrap this with route names + arg types. */
45
45
  declare function useBowlosQuery<T = unknown>(name: string, args?: Record<string, unknown>, options?: UseQueryOptions): UseQueryResult<T>;
46
+ interface UseMutationResult<TArgs, TData> {
47
+ /** Fire the mutation. Resolves with the data, or throws BowlosApiError. */
48
+ run: (args: TArgs) => Promise<TData>;
49
+ data: TData | null;
50
+ error: BowlosApiError | null;
51
+ loading: boolean;
52
+ reset: () => void;
53
+ }
54
+ /** Generic write hook over a gateway route. The typed mutation hooks
55
+ * (`useCancelMyReservation`, etc.) wrap this with a route name + arg type. */
56
+ declare function useBowlosMutation<TArgs extends Record<string, unknown>, TData = unknown>(name: string, options?: {
57
+ auth?: boolean;
58
+ }): UseMutationResult<TArgs, TData>;
46
59
 
47
- export { type AccountStatus as A, BowlosProvider as B, type UseQueryOptions as U, type UseQueryResult as a, type BowlosProviderProps as b, type UseAccountResult as c, useBowlosClient as d, useBowlosQuery as e, useAccount as u };
60
+ export { type AccountStatus as A, BowlosProvider as B, type UseQueryOptions as U, type UseQueryResult as a, type UseMutationResult as b, type BowlosProviderProps as c, type UseAccountResult as d, useBowlosClient as e, useBowlosMutation as f, useBowlosQuery as g, useAccount as u };
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
  import { A as AuthState, g as BowlosClient, h as BowlosClientConfig, l as Customer, L as LinkProfile } from './data-BKlgn8Ln.js';
4
- import { a as BowlosApiError } from './catalog-BxyPJdBL.js';
4
+ import { a as BowlosApiError } from './catalog-BPh01sfG.js';
5
5
 
6
6
  interface BowlosProviderProps {
7
7
  /** A prebuilt client, or pass `config` to have one created and memoized. */
@@ -43,5 +43,18 @@ interface UseQueryResult<T> {
43
43
  /** Generic read hook over a gateway route. The typed data hooks
44
44
  * (`useAvailability`, etc.) will wrap this with route names + arg types. */
45
45
  declare function useBowlosQuery<T = unknown>(name: string, args?: Record<string, unknown>, options?: UseQueryOptions): UseQueryResult<T>;
46
+ interface UseMutationResult<TArgs, TData> {
47
+ /** Fire the mutation. Resolves with the data, or throws BowlosApiError. */
48
+ run: (args: TArgs) => Promise<TData>;
49
+ data: TData | null;
50
+ error: BowlosApiError | null;
51
+ loading: boolean;
52
+ reset: () => void;
53
+ }
54
+ /** Generic write hook over a gateway route. The typed mutation hooks
55
+ * (`useCancelMyReservation`, etc.) wrap this with a route name + arg type. */
56
+ declare function useBowlosMutation<TArgs extends Record<string, unknown>, TData = unknown>(name: string, options?: {
57
+ auth?: boolean;
58
+ }): UseMutationResult<TArgs, TData>;
46
59
 
47
- export { type AccountStatus as A, BowlosProvider as B, type UseQueryOptions as U, type UseQueryResult as a, type BowlosProviderProps as b, type UseAccountResult as c, useBowlosClient as d, useBowlosQuery as e, useAccount as u };
60
+ export { type AccountStatus as A, BowlosProvider as B, type UseQueryOptions as U, type UseQueryResult as a, type UseMutationResult as b, type BowlosProviderProps as c, type UseAccountResult as d, useBowlosClient as e, useBowlosMutation as f, useBowlosQuery as g, useAccount as u };
package/dist/react.cjs CHANGED
@@ -360,103 +360,35 @@ function useBowlosQuery(name, args = {}, options = {}) {
360
360
  }, [enabled, refetch]);
361
361
  return { data, error, loading, refetch };
362
362
  }
363
-
364
- // src/hooks.tsx
365
- function useAvailability(args, options) {
366
- return useBowlosQuery("checkAvailability", args, options);
367
- }
368
- function useBookingPreview(args, options) {
369
- return useBowlosQuery("bookingPreview", args, options);
370
- }
371
- function useAddons(args, options) {
372
- return useBowlosQuery("listPublicAddons", args, options);
373
- }
374
- function useStartTimes(args, options) {
375
- return useBowlosQuery("availableStartTimes", args, options);
376
- }
377
- function useMyReservations(args, options) {
378
- return useBowlosQuery("listMyReservations", args, { ...options, auth: true });
379
- }
380
- function useMyReservationDetail(args, options) {
381
- return useBowlosQuery("getMyReservationDetail", args, { ...options, auth: true });
382
- }
383
- function useMyEventOrders(args, options) {
384
- return useBowlosQuery("listMyEventOrders", args, { ...options, auth: true });
385
- }
386
- function useMyEventOrder(args, options) {
387
- return useBowlosQuery("getMyEventOrder", args, { ...options, auth: true });
388
- }
389
- function useMyMemberships(args, options) {
390
- return useBowlosQuery("listMyMemberships", args, { ...options, auth: true });
391
- }
392
- function useMyMembershipDetail(args, options) {
393
- return useBowlosQuery("getMyMembershipDetail", args, { ...options, auth: true });
394
- }
395
- function useMyLoyalty(args, options) {
396
- return useBowlosQuery("getMyLoyalty", args, { ...options, auth: true });
397
- }
398
- function useMyCredits(args, options) {
399
- return useBowlosQuery("listMyCredits", args, { ...options, auth: true });
400
- }
401
- function useMyPasses(args, options) {
402
- return useBowlosQuery("listMyPasses", args, { ...options, auth: true });
403
- }
404
- function useFlashSale(args, options) {
405
- return useBowlosQuery("getPublicFlashSaleBySlug", args, { ...options, auth: true });
406
- }
407
- function useFlashSales(args, options) {
408
- return useBowlosQuery("listPublicFlashSales", args, options);
409
- }
410
- function useFlashSaleBookingOptions(args, options) {
411
- return useBowlosQuery("getFlashSaleBookingOptions", args, { ...options, auth: true });
412
- }
413
- function useCatalog(args, options) {
414
- return useBowlosQuery("listPublicCatalog", args, options);
415
- }
416
- function useProducts(args, options) {
417
- return useBowlosQuery("listPublicProducts", args, options);
418
- }
419
- function useEvents(args, options) {
420
- return useBowlosQuery("listPublicEvents", args, options);
421
- }
422
- function useEventOffers(args, options) {
423
- return useBowlosQuery("listPublicEventOffers", args, options);
424
- }
425
- function useEventOffer(args, options) {
426
- return useBowlosQuery("getPublicEventOffer", args, options);
427
- }
428
- function usePackages(args, options) {
429
- return useBowlosQuery("listPublicPackages", args, options);
430
- }
431
- function usePackage(args, options) {
432
- return useBowlosQuery("getPublicPackage", args, options);
433
- }
434
- function useCenterHours(args, options) {
435
- return useBowlosQuery("getCenterOperatingHoursForTypes", args, options);
436
- }
437
- function usePackagePreview(args, options) {
438
- return useBowlosQuery("previewPackageOrder", args, { ...options, auth: true });
439
- }
440
- function usePublicMemberships(args, options) {
441
- return useBowlosQuery("listPublicMemberships", args, options);
442
- }
443
- function useGameCards(args, options) {
444
- return useBowlosQuery("listPublicGameCards", args, options);
445
- }
446
- function useGameCardPreview(args, options) {
447
- return useBowlosQuery("previewGameCardOrder", args, { ...options, auth: true });
448
- }
449
- function useEventTicketPreview(args, options) {
450
- return useBowlosQuery("previewEventTicketOrder", args, { ...options, auth: true });
451
- }
452
- function useMembershipPreview(args, options) {
453
- return useBowlosQuery("previewMembershipOrder", args, { ...options, auth: true });
454
- }
455
- function useMembershipSubscriptionPreview(args, options) {
456
- return useBowlosQuery("previewMembershipSubscriptionOrder", args, {
457
- ...options,
458
- auth: true
459
- });
363
+ function useBowlosMutation(name, options = {}) {
364
+ const client = useBowlosClient();
365
+ const auth = options.auth ?? false;
366
+ const [data, setData] = react.useState(null);
367
+ const [error, setError] = react.useState(null);
368
+ const [loading, setLoading] = react.useState(false);
369
+ const run = react.useCallback(
370
+ async (args) => {
371
+ setLoading(true);
372
+ setError(null);
373
+ try {
374
+ const result = await client.call(name, args, { auth });
375
+ setData(result);
376
+ return result;
377
+ } catch (e) {
378
+ if (e instanceof BowlosApiError) setError(e);
379
+ throw e;
380
+ } finally {
381
+ setLoading(false);
382
+ }
383
+ },
384
+ [client, name, auth]
385
+ );
386
+ const reset = react.useCallback(() => {
387
+ setData(null);
388
+ setError(null);
389
+ setLoading(false);
390
+ }, []);
391
+ return { run, data, error, loading, reset };
460
392
  }
461
393
 
462
394
  // src/data.ts
@@ -555,7 +487,152 @@ function abandonCheckout(client, refToken) {
555
487
  return client.call("abandonCheckout", { refToken }, { auth: true });
556
488
  }
557
489
 
558
- // src/use-booking-flow.tsx
490
+ // src/hooks.tsx
491
+ function useAvailability(args, options) {
492
+ return useBowlosQuery("checkAvailability", args, options);
493
+ }
494
+ function useBookingPreview(args, options) {
495
+ return useBowlosQuery("bookingPreview", args, options);
496
+ }
497
+ function useAddons(args, options) {
498
+ return useBowlosQuery("listPublicAddons", args, options);
499
+ }
500
+ function useStartTimes(args, options) {
501
+ return useBowlosQuery("availableStartTimes", args, options);
502
+ }
503
+ function useMyReservations(args, options) {
504
+ return useBowlosQuery("listMyReservations", args, { ...options, auth: true });
505
+ }
506
+ function useMyReservationDetail(args, options) {
507
+ return useBowlosQuery("getMyReservationDetail", args, { ...options, auth: true });
508
+ }
509
+ function useMyEventOrders(args, options) {
510
+ return useBowlosQuery("listMyEventOrders", args, { ...options, auth: true });
511
+ }
512
+ function useMyEventOrder(args, options) {
513
+ return useBowlosQuery("getMyEventOrder", args, { ...options, auth: true });
514
+ }
515
+ function useMyMemberships(args, options) {
516
+ return useBowlosQuery("listMyMemberships", args, { ...options, auth: true });
517
+ }
518
+ function useMyMembershipDetail(args, options) {
519
+ return useBowlosQuery("getMyMembershipDetail", args, { ...options, auth: true });
520
+ }
521
+ function useMyLoyalty(args, options) {
522
+ return useBowlosQuery("getMyLoyalty", args, { ...options, auth: true });
523
+ }
524
+ function useMyCredits(args, options) {
525
+ return useBowlosQuery("listMyCredits", args, { ...options, auth: true });
526
+ }
527
+ function useMyPasses(args, options) {
528
+ return useBowlosQuery("listMyPasses", args, { ...options, auth: true });
529
+ }
530
+ function useMyGameCards(args, options) {
531
+ return useBowlosQuery("listMyGameCards", args, { ...options, auth: true });
532
+ }
533
+ function useReservationCancelPreview(args, options) {
534
+ return useBowlosQuery("previewMyCancellation", args, { ...options, auth: true });
535
+ }
536
+ function useEventOrderCancelPreview(args, options) {
537
+ return useBowlosQuery("previewMyEventOrderCancellation", args, { ...options, auth: true });
538
+ }
539
+ function usePackageOrderCancelPreview(args, options) {
540
+ return useBowlosQuery("previewMyPackageOrderCancellation", args, { ...options, auth: true });
541
+ }
542
+ function useGameCardCancelPreview(args, options) {
543
+ return useBowlosQuery("previewMyGameCardCancellation", args, { ...options, auth: true });
544
+ }
545
+ function useCancelMyReservation() {
546
+ const m = useBowlosMutation("cancelMyReservation", {
547
+ auth: true
548
+ });
549
+ const run = react.useCallback(
550
+ (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
551
+ [m]
552
+ );
553
+ return { ...m, run };
554
+ }
555
+ function useCancelMyEventOrder() {
556
+ const m = useBowlosMutation("cancelMyEventOrder", { auth: true });
557
+ const run = react.useCallback(
558
+ (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
559
+ [m]
560
+ );
561
+ return { ...m, run };
562
+ }
563
+ function useCancelMyPackageOrder() {
564
+ const m = useBowlosMutation("cancelMyPackageOrder", { auth: true });
565
+ const run = react.useCallback(
566
+ (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
567
+ [m]
568
+ );
569
+ return { ...m, run };
570
+ }
571
+ function useCancelMyGameCard() {
572
+ const m = useBowlosMutation("cancelMyGameCard", { auth: true });
573
+ const run = react.useCallback(
574
+ (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
575
+ [m]
576
+ );
577
+ return { ...m, run };
578
+ }
579
+ function useFlashSale(args, options) {
580
+ return useBowlosQuery("getPublicFlashSaleBySlug", args, { ...options, auth: true });
581
+ }
582
+ function useFlashSales(args, options) {
583
+ return useBowlosQuery("listPublicFlashSales", args, options);
584
+ }
585
+ function useFlashSaleBookingOptions(args, options) {
586
+ return useBowlosQuery("getFlashSaleBookingOptions", args, { ...options, auth: true });
587
+ }
588
+ function useCatalog(args, options) {
589
+ return useBowlosQuery("listPublicCatalog", args, options);
590
+ }
591
+ function useProducts(args, options) {
592
+ return useBowlosQuery("listPublicProducts", args, options);
593
+ }
594
+ function useEvents(args, options) {
595
+ return useBowlosQuery("listPublicEvents", args, options);
596
+ }
597
+ function useEventOffers(args, options) {
598
+ return useBowlosQuery("listPublicEventOffers", args, options);
599
+ }
600
+ function useEventOffer(args, options) {
601
+ return useBowlosQuery("getPublicEventOffer", args, options);
602
+ }
603
+ function usePackages(args, options) {
604
+ return useBowlosQuery("listPublicPackages", args, options);
605
+ }
606
+ function usePackage(args, options) {
607
+ return useBowlosQuery("getPublicPackage", args, options);
608
+ }
609
+ function useCenterHours(args, options) {
610
+ return useBowlosQuery("getCenterOperatingHoursForTypes", args, options);
611
+ }
612
+ function usePackagePreview(args, options) {
613
+ return useBowlosQuery("previewPackageOrder", args, { ...options, auth: true });
614
+ }
615
+ function usePublicMemberships(args, options) {
616
+ return useBowlosQuery("listPublicMemberships", args, options);
617
+ }
618
+ function useGameCards(args, options) {
619
+ return useBowlosQuery("listPublicGameCards", args, options);
620
+ }
621
+ function useGameCardPreview(args, options) {
622
+ return useBowlosQuery("previewGameCardOrder", args, { ...options, auth: true });
623
+ }
624
+ function useEventTicketPreview(args, options) {
625
+ return useBowlosQuery("previewEventTicketOrder", args, { ...options, auth: true });
626
+ }
627
+ function useMembershipPreview(args, options) {
628
+ return useBowlosQuery("previewMembershipOrder", args, { ...options, auth: true });
629
+ }
630
+ function useMembershipSubscriptionPreview(args, options) {
631
+ return useBowlosQuery("previewMembershipSubscriptionOrder", args, {
632
+ ...options,
633
+ auth: true
634
+ });
635
+ }
559
636
  var DEFAULT_POLL_MS = 2500;
560
637
  function useBookingFlow() {
561
638
  const client = useBowlosClient();
@@ -972,17 +1049,24 @@ exports.useAvailability = useAvailability;
972
1049
  exports.useBookingFlow = useBookingFlow;
973
1050
  exports.useBookingPreview = useBookingPreview;
974
1051
  exports.useBowlosClient = useBowlosClient;
1052
+ exports.useBowlosMutation = useBowlosMutation;
975
1053
  exports.useBowlosQuery = useBowlosQuery;
1054
+ exports.useCancelMyEventOrder = useCancelMyEventOrder;
1055
+ exports.useCancelMyGameCard = useCancelMyGameCard;
1056
+ exports.useCancelMyPackageOrder = useCancelMyPackageOrder;
1057
+ exports.useCancelMyReservation = useCancelMyReservation;
976
1058
  exports.useCatalog = useCatalog;
977
1059
  exports.useCenterHours = useCenterHours;
978
1060
  exports.useEventOffer = useEventOffer;
979
1061
  exports.useEventOffers = useEventOffers;
1062
+ exports.useEventOrderCancelPreview = useEventOrderCancelPreview;
980
1063
  exports.useEventTicketPreview = useEventTicketPreview;
981
1064
  exports.useEventTicketPurchase = useEventTicketPurchase;
982
1065
  exports.useEvents = useEvents;
983
1066
  exports.useFlashSale = useFlashSale;
984
1067
  exports.useFlashSaleBookingOptions = useFlashSaleBookingOptions;
985
1068
  exports.useFlashSales = useFlashSales;
1069
+ exports.useGameCardCancelPreview = useGameCardCancelPreview;
986
1070
  exports.useGameCardPreview = useGameCardPreview;
987
1071
  exports.useGameCardPurchase = useGameCardPurchase;
988
1072
  exports.useGameCards = useGameCards;
@@ -993,6 +1077,7 @@ exports.useMembershipSubscriptionPreview = useMembershipSubscriptionPreview;
993
1077
  exports.useMyCredits = useMyCredits;
994
1078
  exports.useMyEventOrder = useMyEventOrder;
995
1079
  exports.useMyEventOrders = useMyEventOrders;
1080
+ exports.useMyGameCards = useMyGameCards;
996
1081
  exports.useMyLoyalty = useMyLoyalty;
997
1082
  exports.useMyMembershipDetail = useMyMembershipDetail;
998
1083
  exports.useMyMemberships = useMyMemberships;
@@ -1000,12 +1085,14 @@ exports.useMyPasses = useMyPasses;
1000
1085
  exports.useMyReservationDetail = useMyReservationDetail;
1001
1086
  exports.useMyReservations = useMyReservations;
1002
1087
  exports.usePackage = usePackage;
1088
+ exports.usePackageOrderCancelPreview = usePackageOrderCancelPreview;
1003
1089
  exports.usePackagePreview = usePackagePreview;
1004
1090
  exports.usePackagePurchase = usePackagePurchase;
1005
1091
  exports.usePackages = usePackages;
1006
1092
  exports.useProducts = useProducts;
1007
1093
  exports.usePublicMemberships = usePublicMemberships;
1008
1094
  exports.usePurchase = usePurchase;
1095
+ exports.useReservationCancelPreview = useReservationCancelPreview;
1009
1096
  exports.useStartTimes = useStartTimes;
1010
1097
  //# sourceMappingURL=react.cjs.map
1011
1098
  //# sourceMappingURL=react.cjs.map