@bowlos/reservations 0.34.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 +196 -2
  2. package/README.md +130 -0
  3. package/dist/{account-CsCusw5Z.d.ts → account-DfM2COaz.d.ts} +47 -2
  4. package/dist/{account-Di8nktqp.d.cts → account-oCvYWmO9.d.cts} +47 -2
  5. package/dist/{catalog-DdvLcOrs.d.cts → catalog-DbhdwmnX.d.cts} +4 -1
  6. package/dist/{catalog-DT-ePirK.d.ts → catalog-XkjgPI5C.d.ts} +4 -1
  7. package/dist/{chunk-GIAJQPMM.js → chunk-3JSVEOKG.js} +8 -4
  8. package/dist/chunk-3JSVEOKG.js.map +1 -0
  9. package/dist/{chunk-CAXGTKJQ.js → chunk-TEHRROVY.js} +37 -4
  10. package/dist/chunk-TEHRROVY.js.map +1 -0
  11. package/dist/{chunk-EQH5HDYQ.js → chunk-YAXBZJMI.js} +2 -2
  12. package/dist/{chunk-EQH5HDYQ.js.map → chunk-YAXBZJMI.js.map} +1 -1
  13. package/dist/cli.cjs +5 -3
  14. package/dist/cli.cjs.map +1 -1
  15. package/dist/components.cjs +13 -5
  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 +16 -7
  20. package/dist/components.js.map +1 -1
  21. package/dist/{data-BaHVz6fa.d.cts → data-BJkB-tvM.d.cts} +32 -4
  22. package/dist/{data-BaHVz6fa.d.ts → data-BJkB-tvM.d.ts} +32 -4
  23. package/dist/index.cjs +28 -2
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +4 -4
  26. package/dist/index.d.ts +4 -4
  27. package/dist/index.js +22 -5
  28. package/dist/index.js.map +1 -1
  29. package/dist/payments.d.cts +1 -1
  30. package/dist/payments.d.ts +1 -1
  31. package/dist/{react-DImwA9C9.d.ts → react-0MyyTtE4.d.ts} +2 -2
  32. package/dist/{react-DK1elmLQ.d.cts → react-CWAG4cW0.d.cts} +2 -2
  33. package/dist/react.cjs +43 -3
  34. package/dist/react.cjs.map +1 -1
  35. package/dist/react.d.cts +23 -7
  36. package/dist/react.d.ts +23 -7
  37. package/dist/react.js +3 -3
  38. package/package.json +3 -2
  39. package/templates/center-site/app/book/page.tsx +11 -23
  40. package/templates/center-site/app/catalog/page.tsx +16 -9
  41. package/templates/center-site/package.json +1 -1
  42. package/dist/chunk-CAXGTKJQ.js.map +0 -1
  43. package/dist/chunk-GIAJQPMM.js.map +0 -1
@@ -178,6 +178,14 @@ type AvailabilityArgs = {
178
178
  interface AvailabilityResult {
179
179
  totalUnits: number;
180
180
  busyUnitIds: string[];
181
+ /** Operator-configured noun for a bookable unit (a lane/room/bay), both
182
+ * forms so you pick by count ("1 lane" vs "2 lanes"). Label it
183
+ * "available"/"open", never "free". Optional — older gateways omit it;
184
+ * fall back to "lane"/"lanes". Added v0.35.0. */
185
+ unitNoun?: {
186
+ singular: string;
187
+ plural: string;
188
+ };
181
189
  }
182
190
  type PricingMode = "per_unit_per_hour" | "per_person_per_hour" | "per_game";
183
191
  type BookingAddonSelection = {
@@ -277,9 +285,18 @@ interface BookingQuote {
277
285
  }>;
278
286
  taxTotalCents: number;
279
287
  }>;
288
+ /** Operator-configured noun for this booking's count, resolved by pricing
289
+ * mode (unit → lane/room, per-person → bowler/guest, per-game → game).
290
+ * Both forms so you render "{count} {singular|plural}" — e.g. "1 room",
291
+ * "2 rooms" — instead of hardcoding "lane"/"lanes". Optional — older
292
+ * gateways omit it; fall back to a sensible default. Added v0.35.0. */
293
+ unitNoun?: {
294
+ singular: string;
295
+ plural: string;
296
+ };
280
297
  [key: string]: unknown;
281
298
  }
282
- /** Free units for a product/date/time window (anonymous). */
299
+ /** Available (unoccupied) units for a product/date/time window (anonymous). */
283
300
  declare function checkAvailability(client: BowlosClient, args: AvailabilityArgs): Promise<AvailabilityResult>;
284
301
  /** Authoritative price quote for the chosen inputs. Anonymous by default
285
302
  * (the center's standard online price). Pass `{ auth: true }` when the
@@ -309,7 +326,10 @@ type StartTimesArgs = {
309
326
  * within operating hours, past the booking buffer, and backed by a real price
310
327
  * plan (same pricing engine the quote uses). Anonymous-callable. */
311
328
  declare function listStartTimes(client: BowlosClient, args: StartTimesArgs): Promise<number[]>;
312
- /** Convenience: free units = total minus the busy set (never negative). */
329
+ /** Convenience: available units = total minus the busy set (never negative).
330
+ * This is an availability count of UNOCCUPIED units — it is NOT a
331
+ * complimentary/price signal. Never render it as "free" next to a price
332
+ * (e.g. "2 lanes free"); label it "available"/"open". */
313
333
  declare function availableUnitCount(availability: AvailabilityResult): number;
314
334
  /** Customer identity for a booking (collected in the booking form; the server
315
335
  * links/creates the customer per the booking-flow-only signup rule). */
@@ -445,6 +465,8 @@ type GameCardPreviewArgs = {
445
465
  * total. Drives the headless "Review" step. Computed by the SAME engine as the
446
466
  * PaymentIntent, so it never diverges from what the customer is charged. */
447
467
  interface GameCardPreviewResult {
468
+ tierDiscountCents?: number;
469
+ tierDiscountLabel?: string;
448
470
  subtotalCents: number;
449
471
  taxLines: {
450
472
  rateId: string;
@@ -470,6 +492,8 @@ type EventTicketPreviewArgs = {
470
492
  flashSaleItemId?: string;
471
493
  };
472
494
  interface EventTicketPreviewResult {
495
+ tierDiscountCents?: number;
496
+ tierDiscountLabel?: string;
473
497
  eventName: string;
474
498
  eventDate: string;
475
499
  quantity: number;
@@ -590,6 +614,8 @@ type PackagePreviewArgs = {
590
614
  * total. Drives the headless "Review" step. Computed by the SAME engine as the
591
615
  * PaymentIntent, so it never diverges from what the customer is charged. */
592
616
  interface PackagePreviewResult {
617
+ tierDiscountCents?: number;
618
+ tierDiscountLabel?: string;
593
619
  baseTotalCents: number;
594
620
  addons: {
595
621
  addonId: string;
@@ -631,6 +657,8 @@ type MembershipPreviewArgs = {
631
657
  * by the SAME engine as the PaymentIntent, so it never diverges from what the
632
658
  * customer is charged. */
633
659
  interface MembershipPreviewResult {
660
+ tierDiscountCents?: number;
661
+ tierDiscountLabel?: string;
634
662
  duesCents: number;
635
663
  setupFeeCents: number;
636
664
  subtotalCents: number;
@@ -735,8 +763,8 @@ interface MembershipSubscriptionIntent {
735
763
  declare function createMembershipSubscriptionOrder(client: BowlosClient, args: MembershipSubscriptionArgs): Promise<MembershipSubscriptionIntent>;
736
764
  /** Browser/Node-safe idempotency key for booking creates. */
737
765
  declare function generateIdempotencyKey(): string;
738
- /** Place the inventory hold + open a checkout. Sends the session when present
739
- * (member rates + account credit); falls back to anonymous. */
766
+ /** Place the inventory hold + open a checkout. Requires a signed-in
767
+ * customer — the server rejects a guest. Sends the session bearer. */
740
768
  declare function createBooking(client: BowlosClient, args: CreateBookingArgs): Promise<BookingHold>;
741
769
  /** Mint the Stripe Connect PaymentIntent for a held checkout (by refToken). */
742
770
  declare function createCheckoutPaymentIntent(client: BowlosClient, refToken: string): Promise<PaymentIntentInfo>;
@@ -178,6 +178,14 @@ type AvailabilityArgs = {
178
178
  interface AvailabilityResult {
179
179
  totalUnits: number;
180
180
  busyUnitIds: string[];
181
+ /** Operator-configured noun for a bookable unit (a lane/room/bay), both
182
+ * forms so you pick by count ("1 lane" vs "2 lanes"). Label it
183
+ * "available"/"open", never "free". Optional — older gateways omit it;
184
+ * fall back to "lane"/"lanes". Added v0.35.0. */
185
+ unitNoun?: {
186
+ singular: string;
187
+ plural: string;
188
+ };
181
189
  }
182
190
  type PricingMode = "per_unit_per_hour" | "per_person_per_hour" | "per_game";
183
191
  type BookingAddonSelection = {
@@ -277,9 +285,18 @@ interface BookingQuote {
277
285
  }>;
278
286
  taxTotalCents: number;
279
287
  }>;
288
+ /** Operator-configured noun for this booking's count, resolved by pricing
289
+ * mode (unit → lane/room, per-person → bowler/guest, per-game → game).
290
+ * Both forms so you render "{count} {singular|plural}" — e.g. "1 room",
291
+ * "2 rooms" — instead of hardcoding "lane"/"lanes". Optional — older
292
+ * gateways omit it; fall back to a sensible default. Added v0.35.0. */
293
+ unitNoun?: {
294
+ singular: string;
295
+ plural: string;
296
+ };
280
297
  [key: string]: unknown;
281
298
  }
282
- /** Free units for a product/date/time window (anonymous). */
299
+ /** Available (unoccupied) units for a product/date/time window (anonymous). */
283
300
  declare function checkAvailability(client: BowlosClient, args: AvailabilityArgs): Promise<AvailabilityResult>;
284
301
  /** Authoritative price quote for the chosen inputs. Anonymous by default
285
302
  * (the center's standard online price). Pass `{ auth: true }` when the
@@ -309,7 +326,10 @@ type StartTimesArgs = {
309
326
  * within operating hours, past the booking buffer, and backed by a real price
310
327
  * plan (same pricing engine the quote uses). Anonymous-callable. */
311
328
  declare function listStartTimes(client: BowlosClient, args: StartTimesArgs): Promise<number[]>;
312
- /** Convenience: free units = total minus the busy set (never negative). */
329
+ /** Convenience: available units = total minus the busy set (never negative).
330
+ * This is an availability count of UNOCCUPIED units — it is NOT a
331
+ * complimentary/price signal. Never render it as "free" next to a price
332
+ * (e.g. "2 lanes free"); label it "available"/"open". */
313
333
  declare function availableUnitCount(availability: AvailabilityResult): number;
314
334
  /** Customer identity for a booking (collected in the booking form; the server
315
335
  * links/creates the customer per the booking-flow-only signup rule). */
@@ -445,6 +465,8 @@ type GameCardPreviewArgs = {
445
465
  * total. Drives the headless "Review" step. Computed by the SAME engine as the
446
466
  * PaymentIntent, so it never diverges from what the customer is charged. */
447
467
  interface GameCardPreviewResult {
468
+ tierDiscountCents?: number;
469
+ tierDiscountLabel?: string;
448
470
  subtotalCents: number;
449
471
  taxLines: {
450
472
  rateId: string;
@@ -470,6 +492,8 @@ type EventTicketPreviewArgs = {
470
492
  flashSaleItemId?: string;
471
493
  };
472
494
  interface EventTicketPreviewResult {
495
+ tierDiscountCents?: number;
496
+ tierDiscountLabel?: string;
473
497
  eventName: string;
474
498
  eventDate: string;
475
499
  quantity: number;
@@ -590,6 +614,8 @@ type PackagePreviewArgs = {
590
614
  * total. Drives the headless "Review" step. Computed by the SAME engine as the
591
615
  * PaymentIntent, so it never diverges from what the customer is charged. */
592
616
  interface PackagePreviewResult {
617
+ tierDiscountCents?: number;
618
+ tierDiscountLabel?: string;
593
619
  baseTotalCents: number;
594
620
  addons: {
595
621
  addonId: string;
@@ -631,6 +657,8 @@ type MembershipPreviewArgs = {
631
657
  * by the SAME engine as the PaymentIntent, so it never diverges from what the
632
658
  * customer is charged. */
633
659
  interface MembershipPreviewResult {
660
+ tierDiscountCents?: number;
661
+ tierDiscountLabel?: string;
634
662
  duesCents: number;
635
663
  setupFeeCents: number;
636
664
  subtotalCents: number;
@@ -735,8 +763,8 @@ interface MembershipSubscriptionIntent {
735
763
  declare function createMembershipSubscriptionOrder(client: BowlosClient, args: MembershipSubscriptionArgs): Promise<MembershipSubscriptionIntent>;
736
764
  /** Browser/Node-safe idempotency key for booking creates. */
737
765
  declare function generateIdempotencyKey(): string;
738
- /** Place the inventory hold + open a checkout. Sends the session when present
739
- * (member rates + account credit); falls back to anonymous. */
766
+ /** Place the inventory hold + open a checkout. Requires a signed-in
767
+ * customer — the server rejects a guest. Sends the session bearer. */
740
768
  declare function createBooking(client: BowlosClient, args: CreateBookingArgs): Promise<BookingHold>;
741
769
  /** Mint the Stripe Connect PaymentIntent for a held checkout (by refToken). */
742
770
  declare function createCheckoutPaymentIntent(client: BowlosClient, refToken: string): Promise<PaymentIntentInfo>;
package/dist/index.cjs CHANGED
@@ -8,6 +8,9 @@ var BOWLOS_ERROR_CODES = {
8
8
  ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED",
9
9
  RATE_LIMITED: "RATE_LIMITED",
10
10
  // Auth
11
+ PASSWORD_TOO_WEAK: "PASSWORD_TOO_WEAK",
12
+ CURRENT_PASSWORD_INCORRECT: "CURRENT_PASSWORD_INCORRECT",
13
+ CURRENT_PASSWORD_REQUIRED: "CURRENT_PASSWORD_REQUIRED",
11
14
  INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
12
15
  SIGNUP_FAILED: "SIGNUP_FAILED",
13
16
  // Shared backend codes
@@ -88,7 +91,8 @@ function isConfigErrorCode(code) {
88
91
  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;
89
92
  }
90
93
  function looksLikeExpiredSession(status, code) {
91
- if (isConfigErrorCode(code)) return false;
94
+ if (isConfigErrorCode(code) || code === BOWLOS_ERROR_CODES.CURRENT_PASSWORD_INCORRECT || code === BOWLOS_ERROR_CODES.CURRENT_PASSWORD_REQUIRED)
95
+ return false;
92
96
  return status === 401 || code === BOWLOS_ERROR_CODES.PERMISSION_DENIED || code === BOWLOS_ERROR_CODES.SCOPE_REVOKED;
93
97
  }
94
98
  var BowlosClient = class {
@@ -198,7 +202,7 @@ var BowlosClient = class {
198
202
  }
199
203
  const code = env.error?.code ?? (status === 429 ? BOWLOS_ERROR_CODES.RATE_LIMITED : status === 404 ? BOWLOS_ERROR_CODES.NOT_FOUND : BOWLOS_ERROR_CODES.UNKNOWN);
200
204
  const message = env.error?.message ?? `Request to "${name}" failed (HTTP ${status}).`;
201
- if (auth && !retried && this.store.get() && looksLikeExpiredSession(status, code)) {
205
+ if (name !== "changeMyPassword" && auth && !retried && this.store.get() && looksLikeExpiredSession(status, code)) {
202
206
  const refreshed = await this.tryRefresh();
203
207
  if (refreshed) return this.callInternal(name, args, auth, true, method);
204
208
  }
@@ -772,6 +776,23 @@ function createFlashSaleBooking(client, args) {
772
776
  auth: true
773
777
  });
774
778
  }
779
+ function listSavedCards(client, args) {
780
+ return client.call("listMyPaymentMethods", args, { auth: true });
781
+ }
782
+ function createCardSetup(client, args) {
783
+ return client.call("createSetupIntentForAddingCard", args, { auth: true });
784
+ }
785
+ function removeSavedCard(client, args) {
786
+ return client.call("detachPaymentMethod", args, { auth: true });
787
+ }
788
+ function setDefaultCard(client, args) {
789
+ return client.call("setDefaultPaymentMethod", args, { auth: true });
790
+ }
791
+ async function changePassword(client, args) {
792
+ const result = await client.call("changeMyPassword", args, { auth: true });
793
+ await client.signOut();
794
+ return result;
795
+ }
775
796
 
776
797
  // src/catalog.ts
777
798
  function listCatalog(client, args) {
@@ -867,9 +888,11 @@ exports.cancelMyEventOrder = cancelMyEventOrder;
867
888
  exports.cancelMyGameCard = cancelMyGameCard;
868
889
  exports.cancelMyPackageOrder = cancelMyPackageOrder;
869
890
  exports.cancelMyReservation = cancelMyReservation;
891
+ exports.changePassword = changePassword;
870
892
  exports.checkAvailability = checkAvailability;
871
893
  exports.createBooking = createBooking;
872
894
  exports.createBowlosClient = createBowlosClient;
895
+ exports.createCardSetup = createCardSetup;
873
896
  exports.createCheckoutPaymentIntent = createCheckoutPaymentIntent;
874
897
  exports.createEventTicketOrder = createEventTicketOrder;
875
898
  exports.createFlashSaleBooking = createFlashSaleBooking;
@@ -909,6 +932,7 @@ exports.listPackages = listPackages;
909
932
  exports.listProducts = listProducts;
910
933
  exports.listPublicMemberships = listPublicMemberships;
911
934
  exports.listRetailPricing = listRetailPricing;
935
+ exports.listSavedCards = listSavedCards;
912
936
  exports.listStartTimes = listStartTimes;
913
937
  exports.localStorageTokenStore = localStorageTokenStore;
914
938
  exports.previewEventOrderCancellation = previewEventOrderCancellation;
@@ -920,8 +944,10 @@ exports.previewMembershipSubscription = previewMembershipSubscription;
920
944
  exports.previewPackage = previewPackage;
921
945
  exports.previewPackageOrderCancellation = previewPackageOrderCancellation;
922
946
  exports.previewReservationCancellation = previewReservationCancellation;
947
+ exports.removeSavedCard = removeSavedCard;
923
948
  exports.resolvePackageStartTimesForWeekday = resolvePackageStartTimesForWeekday;
924
949
  exports.runDoctor = runDoctor;
950
+ exports.setDefaultCard = setDefaultCard;
925
951
  exports.splitPackageAddons = splitPackageAddons;
926
952
  exports.toOptionalAddonsInput = toOptionalAddonsInput;
927
953
  exports.usesPerWeekdayStartTimes = usesPerWeekdayStartTimes;