@bowlos/reservations 0.35.0 → 0.36.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.
Files changed (43) hide show
  1. package/HEADLESS.md +182 -1
  2. package/README.md +121 -0
  3. package/dist/{account-BJ5UjC0r.d.ts → account-DfM2COaz.d.ts} +47 -2
  4. package/dist/{account-QoFg8-i1.d.cts → account-oCvYWmO9.d.cts} +47 -2
  5. package/dist/{catalog-p9cwB6Qv.d.cts → catalog-DbhdwmnX.d.cts} +4 -1
  6. package/dist/{catalog-CGitz1PG.d.ts → catalog-XkjgPI5C.d.ts} +4 -1
  7. package/dist/{chunk-UN5E6UEZ.js → chunk-3JSVEOKG.js} +8 -4
  8. package/dist/chunk-3JSVEOKG.js.map +1 -0
  9. package/dist/{chunk-MMSVM3QS.js → chunk-TEHRROVY.js} +37 -4
  10. package/dist/chunk-TEHRROVY.js.map +1 -0
  11. package/dist/{chunk-SMPDCDMB.js → chunk-YAXBZJMI.js} +3 -3
  12. package/dist/chunk-YAXBZJMI.js.map +1 -0
  13. package/dist/cli.cjs +5 -3
  14. package/dist/cli.cjs.map +1 -1
  15. package/dist/components.cjs +1 -2
  16. package/dist/components.cjs.map +1 -1
  17. package/dist/components.d.cts +4 -4
  18. package/dist/components.d.ts +4 -4
  19. package/dist/components.js +3 -3
  20. package/dist/{data-qw8P3JW3.d.cts → data-BJkB-tvM.d.cts} +10 -2
  21. package/dist/{data-qw8P3JW3.d.ts → data-BJkB-tvM.d.ts} +10 -2
  22. package/dist/index.cjs +29 -3
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +4 -4
  25. package/dist/index.d.ts +4 -4
  26. package/dist/index.js +22 -5
  27. package/dist/index.js.map +1 -1
  28. package/dist/payments.d.cts +1 -1
  29. package/dist/payments.d.ts +1 -1
  30. package/dist/{react-C2V1kXnO.d.ts → react-0MyyTtE4.d.ts} +2 -2
  31. package/dist/{react-DtncBQ3b.d.cts → react-CWAG4cW0.d.cts} +2 -2
  32. package/dist/react.cjs +43 -3
  33. package/dist/react.cjs.map +1 -1
  34. package/dist/react.d.cts +22 -6
  35. package/dist/react.d.ts +22 -6
  36. package/dist/react.js +3 -3
  37. package/package.json +3 -2
  38. package/templates/center-site/app/book/page.tsx +11 -23
  39. package/templates/center-site/app/catalog/page.tsx +21 -12
  40. package/templates/center-site/package.json +1 -1
  41. package/dist/chunk-MMSVM3QS.js.map +0 -1
  42. package/dist/chunk-SMPDCDMB.js.map +0 -1
  43. package/dist/chunk-UN5E6UEZ.js.map +0 -1
package/HEADLESS.md CHANGED
@@ -22,6 +22,95 @@ All hooks come from `@bowlos/reservations/react`; the framework-agnostic twins
22
22
 
23
23
  ## Capability map
24
24
 
25
+ ### Saved cards and signed-in password changes (v0.36.0)
26
+
27
+ These APIs require a signed-in customer. Card arguments are
28
+ `{ brandId, centerId }`; remove/default also require `paymentMethodId`.
29
+ The gateway pins scope to the API key. A brand-wide key requires an explicit
30
+ center; a center-scoped key supplies its center. Cards are per connected Stripe
31
+ account and belong only to the caller's customer at that Brand.
32
+
33
+ | Core helper | React hook | Gateway POST route |
34
+ | --- | --- | --- |
35
+ | `listSavedCards` | `useSavedCards(scope, options?)` | `listMyPaymentMethods` |
36
+ | `createCardSetup` | `useCreateCardSetup()` | `createSetupIntentForAddingCard` |
37
+ | `removeSavedCard` | `useRemoveCard()` | `detachPaymentMethod` |
38
+ | `setDefaultCard` | `useSetDefaultCard()` | `setDefaultPaymentMethod` |
39
+ | `changePassword` | `useChangePassword()` | `changeMyPassword` |
40
+
41
+ Core helpers take `(client, args)`; data methods are not on `BowlosClient`. Import helpers
42
+ and types from `@bowlos/reservations`, hooks from `@bowlos/reservations/react`.
43
+ Mutation hooks expose `{ run, data, loading, error, reset }`. `useSavedCards`
44
+ returns `{ data, loading, error, refetch }`; call `refetch()` after confirming a
45
+ setup, removing a card, or changing the default. The list returns
46
+ `{ methods: SavedCard[], chargeable }`; each card has `id`, `brand`, `last4`,
47
+ `expMonth`, `expYear`, `isDefault`. Disable Add when `chargeable` is false;
48
+ viewing/removing cards remains available when the account cannot charge.
49
+
50
+ #### Add a card with Stripe.js
51
+
52
+ ```ts
53
+ import { loadStripe } from "@stripe/stripe-js";
54
+ import { createCardSetup, listSavedCards } from "@bowlos/reservations";
55
+
56
+ const setup = await createCardSetup(client, { brandId, centerId });
57
+ // Always use this response's key/account, including for a flagged Test Account.
58
+ const stripe = await loadStripe(setup.publishableKey, {
59
+ stripeAccount: setup.stripeAccount,
60
+ });
61
+ if (!stripe) throw new Error("Stripe could not load");
62
+ const elements = stripe.elements();
63
+ const card = elements.create("card");
64
+ card.mount("#card-element");
65
+ // On your site's Save card submit:
66
+ const { error } = await stripe.confirmCardSetup(setup.clientSecret, {
67
+ payment_method: { card },
68
+ });
69
+ if (error) throw error;
70
+ // Reload saved cards after confirmation; unmount the element when leaving.
71
+ const cards = await listSavedCards(client, { brandId, centerId });
72
+ ```
73
+
74
+ For a Payment Element, initialize `stripe.elements({ clientSecret:
75
+ setup.clientSecret })`, mount its `payment` element, and call
76
+ `stripe.confirmSetup({ elements, confirmParams: { return_url },
77
+ redirect: "if_required" })`; handle errors and any redirect completion before
78
+ refreshing. `CardSetupResult` also exposes `stripeMode: "test" | "live"`,
79
+ and `merchantDisplayName`. No ephemeral key or Stripe customer ID is returned.
80
+ Never substitute a build-time Stripe key or a different connected account.
81
+ Mode follows center state and `customers.isTestAccount`, matching checkout; API key mode does not override it. Setup intents are limited to 5/hour/customer (`RATE_LIMITED`, 429).
82
+
83
+ #### Change password
84
+
85
+ ```ts
86
+ import { changePassword } from "@bowlos/reservations";
87
+
88
+ await changePassword(client, { currentPassword, newPassword });
89
+ // All sessions are invalidated; show your sign-in screen.
90
+ ```
91
+
92
+ The current password is mandatory. The new password uses the same
93
+ `validatePassword` rules as signup. On success the SDK core helper and
94
+ hook clear the local session with best-effort sign-out. Failed changes preserve
95
+ it. An OAuth-only account cannot use password change.
96
+
97
+ Match `BowlosApiError.code` (hook `error.code`), never message text:
98
+
99
+ - `PASSWORD_TOO_WEAK` (400): new password fails signup strength rules.
100
+ - `CURRENT_PASSWORD_INCORRECT` (400): current password is incorrect.
101
+ - `CURRENT_PASSWORD_REQUIRED` (400): enter the current password; a stale session cannot omit it.
102
+ - `RATE_LIMITED` (429): password attempt lockout or setup-intent budget exhausted.
103
+ - `NOT_FOUND` (404): no password login exists.
104
+ - `PERMISSION_DENIED` (403): no signed-in customer or another customer's card.
105
+ - `KEY_SCOPE_MISMATCH` (403): body scope conflicts with the API key.
106
+ - `VALIDATION_FAILED` (400): missing center context, center outside the Brand, unavailable saved cards,
107
+ or a card used by an active membership (update that membership first).
108
+ - `PAYMENTS_NOT_CONNECTED` / `CONNECT_ACCOUNT_RESTRICTED`: adding a card is unavailable.
109
+
110
+ Exported types: `SavedCardScope`, `SavedCardArgs`, `SavedCard`,
111
+ `SavedCardsResult`, `CardSetupResult`, `ChangePasswordArgs`.
112
+
113
+
25
114
  ### 1. Login gate — browse + price open, **log in to purchase** (v0.27.0)
26
115
 
27
116
  Online booking mirrors the white-label site exactly: **anyone can browse the
@@ -34,7 +123,11 @@ kills conversion.
34
123
  > **Changed in v0.27.0.** Before this, the whole funnel was gated on `signedIn`.
35
124
  > Now: render the form + fetch pricing for anonymous visitors; gate at Review.
36
125
  > The server enforces login on the booking-create mutation regardless (a
37
- > headless site can't accidentally allow an anonymous purchase).
126
+ > headless site can't accidentally allow an anonymous purchase). Minting
127
+ > the payment intent, cancelling that intent, and abandoning the checkout
128
+ > also reject a signed-out caller. The checkout `refToken` identifies the
129
+ > attempt; it is not a session. Pay-link tokens for an existing reservation
130
+ > stay token-gated and do not require a session.
38
131
 
39
132
  What this means for your build:
40
133
 
@@ -825,6 +918,8 @@ Headless function twins (non-React): `getPackage(client, { packageId })`,
825
918
 
826
919
  ## Buying a one-time membership
827
920
 
921
+ **Unreleased / backend:** Self-cancel now stops future Stripe billing at period end; no package change required.
922
+
828
923
  A one-time membership is the same **direct-purchase** lifecycle as a game pass —
829
924
  `useMembershipPurchase` on the shared `usePurchase` engine, no inventory hold, no
830
925
  date/time. Mint a connected-account PaymentIntent → pay with `<BowlosPaymentForm>`
@@ -952,6 +1047,12 @@ subscriptions materialize via webhook; read `getMyMemberships(client, { brandId
952
1047
 
953
1048
  ## Booking a flash-sale item at the sale price (headless)
954
1049
 
1050
+ As of **v0.36.0**, the server applies the event's `loyaltyDiscountEnabled` toggle
1051
+ for signed-in members, using the higher of earned and complimentary tier rank.
1052
+ Use checkout totals for the Review and Pay steps. `breakdown.tierDiscountCents`
1053
+ (reservations) and `tierDiscountCents`/`tierDiscountLabel` (flat preview responses)
1054
+ explain savings already included in the subtotal; do not subtract them again.
1055
+
955
1056
  A flash-sale reservation item books through a **purpose-built path** — never
956
1057
  the regular booking calendar (the sale price only exists on the sale's own
957
1058
  dates/blocks). All reads/creates are signed-in only.
@@ -1131,6 +1232,40 @@ as done and re-read the list.
1131
1232
  `getMyGameCards(client, { brandId })`, etc. (generate the key with
1132
1233
  `generateIdempotencyKey()`).
1133
1234
 
1235
+ ## Frozen purchase description on reservation reads (backend-additive)
1236
+
1237
+ The reservation-detail reads — `useMyReservationDetail` / `getMyReservationDetail`
1238
+ (signed-in account) and the receipt read `getReservationByDisplayId` — now return
1239
+ **frozen, point-in-time purchase info** on `snapshot`, so a headless *My bookings*
1240
+ or *receipt* screen can show the same "what's included" line and reconciling tax
1241
+ that the operator admin, confirmation email, and check-in show. This is a
1242
+ **gateway-additive** change (no SDK version bump; these reads are generic
1243
+ `<T = unknown>`, so you simply widen your own type):
1244
+
1245
+ ```ts
1246
+ type ReservationSnapshot = {
1247
+ finalCents: number;
1248
+ // …existing breakdown (baseSubtotalCents, addonLineItems, appliedDiscount*, reservationFee*)…
1249
+ // Added:
1250
+ purchaseSummary: string | null; // one-line "what's included" (render verbatim)
1251
+ pricePlanName: string | null; // e.g. "Thursday Special" (null = standard rate)
1252
+ pricePlanDescription: string | null;
1253
+ appliedDiscountLabel: string | null; // human label; prefer over the raw discount source
1254
+ shoesIncluded: boolean | null;
1255
+ taxTotalCents: number | null; // show so Total reconciles (base − discount + tax + fee)
1256
+ taxLines: Array<{ label: string; taxableBaseCents: number; taxCents: number }> | null;
1257
+ };
1258
+ ```
1259
+
1260
+ **Point-in-time:** these reflect what the customer bought when they booked — a
1261
+ later product/plan rename or price edit does NOT change a past booking's summary.
1262
+ **Legacy:** reservations booked before this ships return `null` for the new keys;
1263
+ fall back to the product name + whatever breakdown the snapshot already had (never
1264
+ re-derive the summary from current config). **Render guidance:** show
1265
+ `purchaseSummary` as the headline line under the product name, `pricePlanName` as a
1266
+ "Special" chip when non-null, and a tax row from `taxTotalCents` (label from
1267
+ `taxLines[0].label`) above the total.
1268
+
1134
1269
  ## Wallet passes — hide the add-to-wallet once a pass is stale
1135
1270
 
1136
1271
  `useMyPasses({ brandId })` (core: `getMyPasses(client, { brandId })`) lists the
@@ -1368,3 +1503,49 @@ Headless sites do **not** get these from a version bump — apply them by hand.
1368
1503
 
1369
1504
  When you add the next release here, add its row **and** any new capability-map
1370
1505
  section in the same PR.
1506
+
1507
+
1508
+ ### v0.36.0 — Saved cards and current-password verification (2026-10-30, unpublished)
1509
+
1510
+ Headless sites can add account pages using `useSavedCards`,
1511
+ `useCreateCardSetup`, `useRemoveCard`, `useSetDefaultCard`, and
1512
+ `useChangePassword` (or the corresponding core helpers).
1513
+ Follow the saved-card capability map above to confirm the SetupIntent with its
1514
+ returned Stripe key/account, then refetch cards. Password forms must collect
1515
+ `currentPassword` and `newPassword`; handle `CURRENT_PASSWORD_INCORRECT`, `CURRENT_PASSWORD_REQUIRED`, and
1516
+ `PASSWORD_TOO_WEAK`, and return to sign-in after success. No UI component adoption
1517
+ is required.
1518
+
1519
+ Sites on `^0.35.x` must change their dependency range to `^0.36.0` by hand;
1520
+ pre-1.0 caret ranges do not cross minor versions.
1521
+
1522
+ Password changes sign out every device. Offer “Forgot your current password?”
1523
+ beside the current-password field and start the existing email-code reset flow:
1524
+ `client.requestPasswordReset(email)`, then `client.resetPassword(email, code, newPassword)`.
1525
+ The reset page must remain accessible while signed in. Handle change-password
1526
+ errors inline using the new `CURRENT_PASSWORD_INCORRECT` /
1527
+ `CURRENT_PASSWORD_REQUIRED` codes; they are not auth errors and never refresh or
1528
+ clear tokens. Existing `INVALID_CREDENTIALS` and `PERMISSION_DENIED` behavior on
1529
+ other routes is unchanged.
1530
+
1531
+ Includes the unpublished 0.35.1 flash-sale fixes:
1532
+
1533
+ Flash checkout now honors `loyaltyDiscountEnabled` for signed-in tier members,
1534
+ including complimentary tiers. Reservation sessions round once per lane before
1535
+ multiplying by lanes; flat buys round per item. A one-cent floor applies before
1536
+ promo codes, tax, and the Center fee. Membership setup fees and renewals are unchanged.
1537
+
1538
+ Headless adoption: use the server checkout amount; never recompute a charge from
1539
+ public sale prices. `createFlashSaleBooking().breakdown.tierDiscountCents` reports
1540
+ savings already included in `baseSubtotalCents` and `amountDueCents`. Display it as
1541
+ an informational discount line; do not subtract it a second time. Existing sales
1542
+ with the toggle enabled begin applying this benefit when the Convex change deploys.
1543
+
1544
+
1545
+ Checkout replay policy (P8 review fix): retries with the same checkout key retain
1546
+ the attempt's original amount and tier discount, even if the customer's tier
1547
+ changes. Render the checkout response amount/breakdown rather than a new preview;
1548
+ the PaymentIntent uses that same pinned amount. Flash reservation retries whose
1549
+ frozen preview is missing or inconsistent return `CHECKOUT_EXPIRED`: request a
1550
+ fresh quote and generate a new key. This also applies after an interruption
1551
+ between persisting the attempt and creating its PaymentIntent.
package/README.md CHANGED
@@ -460,3 +460,124 @@ try {
460
460
  ## License
461
461
 
462
462
  MIT
463
+
464
+
465
+ ## Saved cards and signed-in password changes (v0.36.0)
466
+
467
+ These APIs require a signed-in customer. Card arguments are
468
+ `{ brandId, centerId }`; remove/default also require `paymentMethodId`.
469
+ The gateway pins scope to the API key. A brand-wide key requires an explicit
470
+ center; a center-scoped key supplies its center. Cards are per connected Stripe
471
+ account and belong only to the caller's customer at that Brand.
472
+
473
+ | Core helper | React hook | Gateway POST route |
474
+ | --- | --- | --- |
475
+ | `listSavedCards` | `useSavedCards(scope, options?)` | `listMyPaymentMethods` |
476
+ | `createCardSetup` | `useCreateCardSetup()` | `createSetupIntentForAddingCard` |
477
+ | `removeSavedCard` | `useRemoveCard()` | `detachPaymentMethod` |
478
+ | `setDefaultCard` | `useSetDefaultCard()` | `setDefaultPaymentMethod` |
479
+ | `changePassword` | `useChangePassword()` | `changeMyPassword` |
480
+
481
+ Core helpers take `(client, args)`; data methods are not on `BowlosClient`. Import helpers
482
+ and types from `@bowlos/reservations`, hooks from `@bowlos/reservations/react`.
483
+ Mutation hooks expose `{ run, data, loading, error, reset }`. `useSavedCards`
484
+ returns `{ data, loading, error, refetch }`; call `refetch()` after confirming a
485
+ setup, removing a card, or changing the default. The list returns
486
+ `{ methods: SavedCard[], chargeable }`; each card has `id`, `brand`, `last4`,
487
+ `expMonth`, `expYear`, `isDefault`. Disable Add when `chargeable` is false;
488
+ viewing/removing cards remains available when the account cannot charge.
489
+
490
+ ### Add a card with Stripe.js
491
+
492
+ ```ts
493
+ import { loadStripe } from "@stripe/stripe-js";
494
+ import { createCardSetup, listSavedCards } from "@bowlos/reservations";
495
+
496
+ const setup = await createCardSetup(client, { brandId, centerId });
497
+ // Always use this response's key/account, including for a flagged Test Account.
498
+ const stripe = await loadStripe(setup.publishableKey, {
499
+ stripeAccount: setup.stripeAccount,
500
+ });
501
+ if (!stripe) throw new Error("Stripe could not load");
502
+ const elements = stripe.elements();
503
+ const card = elements.create("card");
504
+ card.mount("#card-element");
505
+ // On your site's Save card submit:
506
+ const { error } = await stripe.confirmCardSetup(setup.clientSecret, {
507
+ payment_method: { card },
508
+ });
509
+ if (error) throw error;
510
+ // Reload saved cards after confirmation; unmount the element when leaving.
511
+ const cards = await listSavedCards(client, { brandId, centerId });
512
+ ```
513
+
514
+ For a Payment Element, initialize `stripe.elements({ clientSecret:
515
+ setup.clientSecret })`, mount its `payment` element, and call
516
+ `stripe.confirmSetup({ elements, confirmParams: { return_url },
517
+ redirect: "if_required" })`; handle errors and any redirect completion before
518
+ refreshing. `CardSetupResult` also exposes `stripeMode: "test" | "live"`,
519
+ and `merchantDisplayName`. No ephemeral key or Stripe customer ID is returned.
520
+ Never substitute a build-time Stripe key or a different connected account.
521
+ Mode follows center state and `customers.isTestAccount`, matching checkout; API key mode does not override it. Setup intents are limited to 5/hour/customer (`RATE_LIMITED`, 429).
522
+
523
+ ### Change password
524
+
525
+ ```ts
526
+ import { changePassword } from "@bowlos/reservations";
527
+
528
+ await changePassword(client, { currentPassword, newPassword });
529
+ // All sessions are invalidated; show your sign-in screen.
530
+ ```
531
+
532
+ The current password is mandatory. The new password uses the same
533
+ `validatePassword` rules as signup. On success the SDK core helper and
534
+ hook clear the local session with best-effort sign-out. Failed changes preserve
535
+ it. An OAuth-only account cannot use password change.
536
+
537
+ Match `BowlosApiError.code` (hook `error.code`), never message text:
538
+
539
+ - `PASSWORD_TOO_WEAK` (400): new password fails signup strength rules.
540
+ - `CURRENT_PASSWORD_INCORRECT` (400): current password is incorrect.
541
+ - `CURRENT_PASSWORD_REQUIRED` (400): enter the current password; a stale session cannot omit it.
542
+ - `RATE_LIMITED` (429): password attempt lockout or setup-intent budget exhausted.
543
+ - `NOT_FOUND` (404): no password login exists.
544
+ - `PERMISSION_DENIED` (403): no signed-in customer or another customer's card.
545
+ - `KEY_SCOPE_MISMATCH` (403): body scope conflicts with the API key.
546
+ - `VALIDATION_FAILED` (400): missing center context, center outside the Brand, unavailable saved cards,
547
+ or a card used by an active membership (update that membership first).
548
+ - `PAYMENTS_NOT_CONNECTED` / `CONNECT_ACCOUNT_RESTRICTED`: adding a card is unavailable.
549
+
550
+ Exported types: `SavedCardScope`, `SavedCardArgs`, `SavedCard`,
551
+ `SavedCardsResult`, `CardSetupResult`, `ChangePasswordArgs`.
552
+
553
+ ### v0.36.0 — Saved cards and change password (2026-10-30, unpublished)
554
+
555
+ Adds the five core helpers and five React hooks above, typed
556
+ SetupIntent configuration, scoped gateway access, and current-password
557
+ verification. Existing headless sites add their own card/password forms using
558
+ [the headless guide](./HEADLESS.md).
559
+
560
+ Sites on `^0.35.x` must change their dependency range to `^0.36.0` by hand;
561
+ pre-1.0 caret ranges do not cross minor versions.
562
+
563
+ Password changes sign out every device. Offer “Forgot your current password?”
564
+ beside the current-password field and start the existing email-code reset flow:
565
+ `client.requestPasswordReset(email)`, then `client.resetPassword(email, code, newPassword)`.
566
+ The reset page must remain accessible while signed in. Handle change-password
567
+ errors inline using the new `CURRENT_PASSWORD_INCORRECT` /
568
+ `CURRENT_PASSWORD_REQUIRED` codes; they are not auth errors and never refresh or
569
+ clear tokens. Existing `INVALID_CREDENTIALS` and `PERMISSION_DENIED` behavior on
570
+ other routes is unchanged.
571
+
572
+ Includes the unpublished 0.35.1 flash-sale fixes:
573
+
574
+ Flash checkout now honors `loyaltyDiscountEnabled` for signed-in tier members,
575
+ including complimentary tiers. Reservation sessions round once per lane before
576
+ multiplying by lanes; flat buys round per item. A one-cent floor applies before
577
+ promo codes, tax, and the Center fee. Membership setup fees and renewals are unchanged.
578
+
579
+ Headless adoption: use the server checkout amount; never recompute a charge from
580
+ public sale prices. `createFlashSaleBooking().breakdown.tierDiscountCents` reports
581
+ savings already included in `baseSubtotalCents` and `amountDueCents`. Display it as
582
+ an informational discount line; do not subtract it a second time. Existing sales
583
+ with the toggle enabled begin applying this benefit when the Convex change deploys.
@@ -1,4 +1,4 @@
1
- import { g as BowlosClient } from './data-qw8P3JW3.js';
1
+ import { g as BowlosClient } from './data-BJkB-tvM.js';
2
2
 
3
3
  /**
4
4
  * Typed account + flash reads for @bowlos/reservations.
@@ -145,6 +145,8 @@ interface FlashSaleBookingResult {
145
145
  amountDueCents: number;
146
146
  holdExpiresAt: number;
147
147
  breakdown: {
148
+ /** Tier savings already removed from baseSubtotalCents; do not subtract again. */
149
+ tierDiscountCents: number;
148
150
  baseSubtotalCents: number;
149
151
  reservationFeeCents: number;
150
152
  reservationFeeLabel: string | null;
@@ -161,5 +163,48 @@ interface FlashSaleBookingResult {
161
163
  * list — never the regular booking calendar.
162
164
  */
163
165
  declare function createFlashSaleBooking(client: BowlosClient, args: CreateFlashSaleBookingArgs): Promise<FlashSaleBookingResult>;
166
+ /** Saved cards belong to the active location's connected Stripe account. */
167
+ type SavedCardScope = {
168
+ brandId: string;
169
+ centerId: string;
170
+ };
171
+ type SavedCardArgs = SavedCardScope & {
172
+ paymentMethodId: string;
173
+ };
174
+ interface SavedCard {
175
+ id: string;
176
+ brand: string;
177
+ last4: string;
178
+ expMonth: number;
179
+ expYear: number;
180
+ isDefault: boolean;
181
+ }
182
+ interface SavedCardsResult {
183
+ methods: SavedCard[];
184
+ chargeable: boolean;
185
+ }
186
+ interface CardSetupResult {
187
+ clientSecret: string;
188
+ publishableKey: string;
189
+ stripeAccount: string;
190
+ stripeMode: "test" | "live";
191
+ merchantDisplayName: string;
192
+ }
193
+ type ChangePasswordArgs = {
194
+ currentPassword: string;
195
+ newPassword: string;
196
+ };
197
+ declare function listSavedCards(client: BowlosClient, args: SavedCardScope): Promise<SavedCardsResult>;
198
+ declare function createCardSetup(client: BowlosClient, args: SavedCardScope): Promise<CardSetupResult>;
199
+ declare function removeSavedCard(client: BowlosClient, args: SavedCardArgs): Promise<{
200
+ detached: boolean;
201
+ }>;
202
+ declare function setDefaultCard(client: BowlosClient, args: SavedCardArgs): Promise<{
203
+ ok: boolean;
204
+ }>;
205
+ /** Success invalidates all sessions; discard local tokens and show sign-in. */
206
+ declare function changePassword(client: BowlosClient, args: ChangePasswordArgs): Promise<{
207
+ ok: true;
208
+ }>;
164
209
 
165
- export { previewGameCardCancellation as A, type BrandScoped as B, type CancelPreview as C, previewPackageOrderCancellation as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type GameCardCancelArgs as G, previewReservationCancellation as H, type MembershipDetailArgs as M, type OrderCancelArgs as O, type ReservationCancelArgs as R, type CancelResult as a, type CreateFlashSaleBookingArgs as b, type FlashSaleArgs as c, type FlashSaleBookingResult as d, type FlashSalesArgs as e, type MyGameCard as f, type ReservationDetailArgs as g, cancelMyEventOrder as h, cancelMyGameCard as i, cancelMyPackageOrder as j, cancelMyReservation as k, createFlashSaleBooking as l, getFlashSale as m, getFlashSaleBookingOptions as n, getFlashSales as o, getMyCredits as p, getMyEventOrder as q, getMyEventOrders as r, getMyGameCards as s, getMyLoyalty as t, getMyMembershipDetail as u, getMyMemberships as v, getMyPasses as w, getMyReservationDetail as x, getMyReservations as y, previewEventOrderCancellation as z };
210
+ export { getMyLoyalty as A, type BrandScoped as B, type CancelPreview as C, getMyMembershipDetail as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type GameCardCancelArgs as G, getMyMemberships as H, getMyPasses as I, getMyReservationDetail as J, getMyReservations as K, listSavedCards as L, type MembershipDetailArgs as M, previewEventOrderCancellation as N, type OrderCancelArgs as O, previewGameCardCancellation as P, previewPackageOrderCancellation as Q, type ReservationCancelArgs as R, type SavedCard as S, previewReservationCancellation as T, removeSavedCard as U, setDefaultCard as V, type CancelResult as a, type CardSetupResult as b, type ChangePasswordArgs as c, type CreateFlashSaleBookingArgs as d, type FlashSaleArgs as e, type FlashSaleBookingResult as f, type FlashSalesArgs as g, type MyGameCard as h, type ReservationDetailArgs as i, type SavedCardArgs as j, type SavedCardScope as k, type SavedCardsResult as l, cancelMyEventOrder as m, cancelMyGameCard as n, cancelMyPackageOrder as o, cancelMyReservation as p, changePassword as q, createCardSetup as r, createFlashSaleBooking as s, getFlashSale as t, getFlashSaleBookingOptions as u, getFlashSales as v, getMyCredits as w, getMyEventOrder as x, getMyEventOrders as y, getMyGameCards as z };
@@ -1,4 +1,4 @@
1
- import { g as BowlosClient } from './data-qw8P3JW3.cjs';
1
+ import { g as BowlosClient } from './data-BJkB-tvM.cjs';
2
2
 
3
3
  /**
4
4
  * Typed account + flash reads for @bowlos/reservations.
@@ -145,6 +145,8 @@ interface FlashSaleBookingResult {
145
145
  amountDueCents: number;
146
146
  holdExpiresAt: number;
147
147
  breakdown: {
148
+ /** Tier savings already removed from baseSubtotalCents; do not subtract again. */
149
+ tierDiscountCents: number;
148
150
  baseSubtotalCents: number;
149
151
  reservationFeeCents: number;
150
152
  reservationFeeLabel: string | null;
@@ -161,5 +163,48 @@ interface FlashSaleBookingResult {
161
163
  * list — never the regular booking calendar.
162
164
  */
163
165
  declare function createFlashSaleBooking(client: BowlosClient, args: CreateFlashSaleBookingArgs): Promise<FlashSaleBookingResult>;
166
+ /** Saved cards belong to the active location's connected Stripe account. */
167
+ type SavedCardScope = {
168
+ brandId: string;
169
+ centerId: string;
170
+ };
171
+ type SavedCardArgs = SavedCardScope & {
172
+ paymentMethodId: string;
173
+ };
174
+ interface SavedCard {
175
+ id: string;
176
+ brand: string;
177
+ last4: string;
178
+ expMonth: number;
179
+ expYear: number;
180
+ isDefault: boolean;
181
+ }
182
+ interface SavedCardsResult {
183
+ methods: SavedCard[];
184
+ chargeable: boolean;
185
+ }
186
+ interface CardSetupResult {
187
+ clientSecret: string;
188
+ publishableKey: string;
189
+ stripeAccount: string;
190
+ stripeMode: "test" | "live";
191
+ merchantDisplayName: string;
192
+ }
193
+ type ChangePasswordArgs = {
194
+ currentPassword: string;
195
+ newPassword: string;
196
+ };
197
+ declare function listSavedCards(client: BowlosClient, args: SavedCardScope): Promise<SavedCardsResult>;
198
+ declare function createCardSetup(client: BowlosClient, args: SavedCardScope): Promise<CardSetupResult>;
199
+ declare function removeSavedCard(client: BowlosClient, args: SavedCardArgs): Promise<{
200
+ detached: boolean;
201
+ }>;
202
+ declare function setDefaultCard(client: BowlosClient, args: SavedCardArgs): Promise<{
203
+ ok: boolean;
204
+ }>;
205
+ /** Success invalidates all sessions; discard local tokens and show sign-in. */
206
+ declare function changePassword(client: BowlosClient, args: ChangePasswordArgs): Promise<{
207
+ ok: true;
208
+ }>;
164
209
 
165
- export { previewGameCardCancellation as A, type BrandScoped as B, type CancelPreview as C, previewPackageOrderCancellation as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type GameCardCancelArgs as G, previewReservationCancellation as H, type MembershipDetailArgs as M, type OrderCancelArgs as O, type ReservationCancelArgs as R, type CancelResult as a, type CreateFlashSaleBookingArgs as b, type FlashSaleArgs as c, type FlashSaleBookingResult as d, type FlashSalesArgs as e, type MyGameCard as f, type ReservationDetailArgs as g, cancelMyEventOrder as h, cancelMyGameCard as i, cancelMyPackageOrder as j, cancelMyReservation as k, createFlashSaleBooking as l, getFlashSale as m, getFlashSaleBookingOptions as n, getFlashSales as o, getMyCredits as p, getMyEventOrder as q, getMyEventOrders as r, getMyGameCards as s, getMyLoyalty as t, getMyMembershipDetail as u, getMyMemberships as v, getMyPasses as w, getMyReservationDetail as x, getMyReservations as y, previewEventOrderCancellation as z };
210
+ export { getMyLoyalty as A, type BrandScoped as B, type CancelPreview as C, getMyMembershipDetail as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type GameCardCancelArgs as G, getMyMemberships as H, getMyPasses as I, getMyReservationDetail as J, getMyReservations as K, listSavedCards as L, type MembershipDetailArgs as M, previewEventOrderCancellation as N, type OrderCancelArgs as O, previewGameCardCancellation as P, previewPackageOrderCancellation as Q, type ReservationCancelArgs as R, type SavedCard as S, previewReservationCancellation as T, removeSavedCard as U, setDefaultCard as V, type CancelResult as a, type CardSetupResult as b, type ChangePasswordArgs as c, type CreateFlashSaleBookingArgs as d, type FlashSaleArgs as e, type FlashSaleBookingResult as f, type FlashSalesArgs as g, type MyGameCard as h, type ReservationDetailArgs as i, type SavedCardArgs as j, type SavedCardScope as k, type SavedCardsResult as l, cancelMyEventOrder as m, cancelMyGameCard as n, cancelMyPackageOrder as o, cancelMyReservation as p, changePassword as q, createCardSetup as r, createFlashSaleBooking as s, getFlashSale as t, getFlashSaleBookingOptions as u, getFlashSales as v, getMyCredits as w, getMyEventOrder as x, getMyEventOrders as y, getMyGameCards as z };
@@ -1,4 +1,4 @@
1
- import { g as BowlosClient } from './data-qw8P3JW3.cjs';
1
+ import { g as BowlosClient } from './data-BJkB-tvM.cjs';
2
2
 
3
3
  /**
4
4
  * Error model for the BowlOS Reservations SDK.
@@ -17,6 +17,9 @@ declare const BOWLOS_ERROR_CODES: {
17
17
  readonly API_KEY_INVALID: "API_KEY_INVALID";
18
18
  readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
19
19
  readonly RATE_LIMITED: "RATE_LIMITED";
20
+ readonly PASSWORD_TOO_WEAK: "PASSWORD_TOO_WEAK";
21
+ readonly CURRENT_PASSWORD_INCORRECT: "CURRENT_PASSWORD_INCORRECT";
22
+ readonly CURRENT_PASSWORD_REQUIRED: "CURRENT_PASSWORD_REQUIRED";
20
23
  readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
21
24
  readonly SIGNUP_FAILED: "SIGNUP_FAILED";
22
25
  readonly VALIDATION_FAILED: "VALIDATION_FAILED";
@@ -1,4 +1,4 @@
1
- import { g as BowlosClient } from './data-qw8P3JW3.js';
1
+ import { g as BowlosClient } from './data-BJkB-tvM.js';
2
2
 
3
3
  /**
4
4
  * Error model for the BowlOS Reservations SDK.
@@ -17,6 +17,9 @@ declare const BOWLOS_ERROR_CODES: {
17
17
  readonly API_KEY_INVALID: "API_KEY_INVALID";
18
18
  readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
19
19
  readonly RATE_LIMITED: "RATE_LIMITED";
20
+ readonly PASSWORD_TOO_WEAK: "PASSWORD_TOO_WEAK";
21
+ readonly CURRENT_PASSWORD_INCORRECT: "CURRENT_PASSWORD_INCORRECT";
22
+ readonly CURRENT_PASSWORD_REQUIRED: "CURRENT_PASSWORD_REQUIRED";
20
23
  readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
21
24
  readonly SIGNUP_FAILED: "SIGNUP_FAILED";
22
25
  readonly VALIDATION_FAILED: "VALIDATION_FAILED";
@@ -6,6 +6,9 @@ var BOWLOS_ERROR_CODES = {
6
6
  ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED",
7
7
  RATE_LIMITED: "RATE_LIMITED",
8
8
  // Auth
9
+ PASSWORD_TOO_WEAK: "PASSWORD_TOO_WEAK",
10
+ CURRENT_PASSWORD_INCORRECT: "CURRENT_PASSWORD_INCORRECT",
11
+ CURRENT_PASSWORD_REQUIRED: "CURRENT_PASSWORD_REQUIRED",
9
12
  INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
10
13
  SIGNUP_FAILED: "SIGNUP_FAILED",
11
14
  // Shared backend codes
@@ -86,7 +89,8 @@ function isConfigErrorCode(code) {
86
89
  return code === BOWLOS_ERROR_CODES.API_KEY_MISSING || code === BOWLOS_ERROR_CODES.API_KEY_INVALID || code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED || code === BOWLOS_ERROR_CODES.RATE_LIMITED;
87
90
  }
88
91
  function looksLikeExpiredSession(status, code) {
89
- if (isConfigErrorCode(code)) return false;
92
+ if (isConfigErrorCode(code) || code === BOWLOS_ERROR_CODES.CURRENT_PASSWORD_INCORRECT || code === BOWLOS_ERROR_CODES.CURRENT_PASSWORD_REQUIRED)
93
+ return false;
90
94
  return status === 401 || code === BOWLOS_ERROR_CODES.PERMISSION_DENIED || code === BOWLOS_ERROR_CODES.SCOPE_REVOKED;
91
95
  }
92
96
  var BowlosClient = class {
@@ -196,7 +200,7 @@ var BowlosClient = class {
196
200
  }
197
201
  const code = env.error?.code ?? (status === 429 ? BOWLOS_ERROR_CODES.RATE_LIMITED : status === 404 ? BOWLOS_ERROR_CODES.NOT_FOUND : BOWLOS_ERROR_CODES.UNKNOWN);
198
202
  const message = env.error?.message ?? `Request to "${name}" failed (HTTP ${status}).`;
199
- if (auth && !retried && this.store.get() && looksLikeExpiredSession(status, code)) {
203
+ if (name !== "changeMyPassword" && auth && !retried && this.store.get() && looksLikeExpiredSession(status, code)) {
200
204
  const refreshed = await this.tryRefresh();
201
205
  if (refreshed) return this.callInternal(name, args, auth, true, method);
202
206
  }
@@ -470,5 +474,5 @@ function abandonCheckout(client, refToken) {
470
474
  }
471
475
 
472
476
  export { BOWLOS_ERROR_CODES, BowlosApiError, BowlosClient, abandonCheckout, availableUnitCount, bookingPreview, checkAvailability, createBooking, createBowlosClient, createCheckoutPaymentIntent, createEventTicketOrder, createGameCardOrder, createMembershipOrder, createMembershipSubscriptionOrder, createPackageOrder, generateIdempotencyKey, getCheckoutStatus, getEventTicketStatus, getGameCardStatus, getMembershipStatus, getPackageStatus, listAddons, listStartTimes, localStorageTokenStore, previewEventTicket, previewGameCard, previewMembership, previewMembershipSubscription, previewPackage };
473
- //# sourceMappingURL=chunk-UN5E6UEZ.js.map
474
- //# sourceMappingURL=chunk-UN5E6UEZ.js.map
477
+ //# sourceMappingURL=chunk-3JSVEOKG.js.map
478
+ //# sourceMappingURL=chunk-3JSVEOKG.js.map