@bowlos/reservations 0.31.0 → 0.34.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 (35) hide show
  1. package/HEADLESS.md +135 -20
  2. package/README.md +27 -0
  3. package/dist/{account-DVAwhiki.d.ts → account-CsCusw5Z.d.ts} +1 -1
  4. package/dist/{account-BZ-lZcs5.d.cts → account-Di8nktqp.d.cts} +1 -1
  5. package/dist/{catalog-Ck_HLOff.d.ts → catalog-DT-ePirK.d.ts} +1 -1
  6. package/dist/{catalog-LU1sl0gc.d.cts → catalog-DdvLcOrs.d.cts} +1 -1
  7. package/dist/{chunk-S5GEG7SW.js → chunk-CAXGTKJQ.js} +3 -3
  8. package/dist/{chunk-S5GEG7SW.js.map → chunk-CAXGTKJQ.js.map} +1 -1
  9. package/dist/{chunk-P5YWNLEC.js → chunk-GIAJQPMM.js} +2 -2
  10. package/dist/{chunk-P5YWNLEC.js.map → chunk-GIAJQPMM.js.map} +1 -1
  11. package/dist/components.cjs +54 -17
  12. package/dist/components.cjs.map +1 -1
  13. package/dist/components.d.cts +4 -4
  14. package/dist/components.d.ts +4 -4
  15. package/dist/components.js +56 -19
  16. package/dist/components.js.map +1 -1
  17. package/dist/{data-BzO2guh0.d.cts → data-BaHVz6fa.d.cts} +60 -1
  18. package/dist/{data-BzO2guh0.d.ts → data-BaHVz6fa.d.ts} +60 -1
  19. package/dist/index.cjs +27 -0
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +54 -5
  22. package/dist/index.d.ts +54 -5
  23. package/dist/index.js +28 -3
  24. package/dist/index.js.map +1 -1
  25. package/dist/payments.d.cts +1 -1
  26. package/dist/payments.d.ts +1 -1
  27. package/dist/{react-RNgTkCVk.d.ts → react-DImwA9C9.d.ts} +2 -2
  28. package/dist/{react-CX-zIAb5.d.cts → react-DK1elmLQ.d.cts} +2 -2
  29. package/dist/react.cjs.map +1 -1
  30. package/dist/react.d.cts +5 -5
  31. package/dist/react.d.ts +5 -5
  32. package/dist/react.js +3 -3
  33. package/package.json +1 -1
  34. package/templates/center-site/app/catalog/page.tsx +10 -8
  35. package/templates/center-site/package.json +1 -1
@@ -215,10 +215,52 @@ type BookingPreviewArgs = {
215
215
  * price plan, tax override, and Center fee override/inheritance. */
216
216
  eventOfferSlug?: string;
217
217
  };
218
+ /** One add-on line on a plan quote. A plan-included add-on (e.g. shoes on a
219
+ * "Thursday Special") is already dropped from this list — it won't appear. */
220
+ interface BookingQuoteAddonLine {
221
+ addonId: string;
222
+ addonName: string;
223
+ quantity: number;
224
+ unitPriceCents: number;
225
+ lineSubtotalCents: number;
226
+ rateMode?: string;
227
+ }
228
+ /** Per-plan price breakdown. Render THESE fields to itemize the order — do not
229
+ * reconstruct a base by subtracting tax/fee/add-ons from the total, and do not
230
+ * recompute the discount client-side. `preDiscountTotalCents` is the original
231
+ * (base + add-ons, before discount); `appliedDiscount` is present only when a
232
+ * discount applied; `finalCents` is the subtotal after discount, BEFORE tax +
233
+ * fee. The all-in charge is `totalCentsPerPlan[samePlanId].totalCents`. */
234
+ interface BookingQuotePlan {
235
+ pricePlanId: string;
236
+ pricePlanName: string;
237
+ pricePlanDescription?: string;
238
+ baseSubtotalCents: number;
239
+ addonSubtotalCents: number;
240
+ addonLineItems: BookingQuoteAddonLine[];
241
+ preDiscountTotalCents: number;
242
+ /** Present only when a discount applied. `.label` is display text
243
+ * ("Online booking discount"); `.amountCents` is the amount to subtract. */
244
+ appliedDiscount?: {
245
+ amountCents: number;
246
+ label: string;
247
+ source: string;
248
+ };
249
+ /** Subtotal after discount, before tax + fee. */
250
+ finalCents: number;
251
+ /** True when this plan/special bundles shoes — hide the shoe add-on selector
252
+ * and show a "Shoes included" line instead of a priced shoe row. */
253
+ shoesIncluded?: boolean;
254
+ }
218
255
  /** The price quote. Headline fields are typed; the engine's full breakdown
219
- * (line items, discounts, tax, credit) is passed through. */
256
+ * (line items, discounts, tax, credit) is passed through. Join `plans`,
257
+ * `taxLinesPerPlan`, and `totalCentsPerPlan` by `pricePlanId` — never index
258
+ * `[0]` blindly when more than one plan can be returned. */
220
259
  interface BookingQuote {
221
260
  reservationFee: Record<string, unknown> | null;
261
+ /** Per-plan breakdown (name, original price, applied discount, line items).
262
+ * Optional for back-compat with older cores that didn't type it. */
263
+ plans?: BookingQuotePlan[];
222
264
  totalCentsPerPlan: Array<{
223
265
  pricePlanId: string;
224
266
  totalCents: number;
@@ -357,6 +399,9 @@ type GameCardPurchaseArgs = {
357
399
  templateId: string;
358
400
  idempotencyKey?: string;
359
401
  shareToken?: string;
402
+ /** v0.32.0: when set, the buy redeems this flash-sale item at its sale price
403
+ * (the flash sale must be Live; the server validates the item matches). */
404
+ flashSaleItemId?: string;
360
405
  };
361
406
  /** The connected-account PaymentIntent for a game-pass purchase. Confirm it with
362
407
  * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.
@@ -392,6 +437,8 @@ declare function getGameCardStatus(client: BowlosClient, refToken: string): Prom
392
437
  type GameCardPreviewArgs = {
393
438
  templateId: string;
394
439
  shareToken?: string;
440
+ /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */
441
+ flashSaleItemId?: string;
395
442
  };
396
443
  /** Server-computed itemized quote for a game-pass purchase — the base price,
397
444
  * tax lines, the selling Center's booking fee, and the authoritative grand
@@ -419,6 +466,8 @@ declare function previewGameCard(client: BowlosClient, args: GameCardPreviewArgs
419
466
  type EventTicketPreviewArgs = {
420
467
  eventOfferId: string;
421
468
  quantity: number;
469
+ /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */
470
+ flashSaleItemId?: string;
422
471
  };
423
472
  interface EventTicketPreviewResult {
424
473
  eventName: string;
@@ -447,6 +496,8 @@ type EventTicketPurchaseArgs = {
447
496
  eventOfferId: string;
448
497
  quantity: number;
449
498
  idempotencyKey?: string;
499
+ /** v0.32.0: redeem this flash-sale item at its sale price. */
500
+ flashSaleItemId?: string;
450
501
  };
451
502
  /** The connected-account PaymentIntent for a ticket-mode event purchase.
452
503
  * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` +
@@ -492,6 +543,8 @@ type PackagePurchaseArgs = {
492
543
  scheduledStartMinute: number;
493
544
  idempotencyKey?: string;
494
545
  shareToken?: string;
546
+ /** v0.32.0: redeem this flash-sale item at its sale price. */
547
+ flashSaleItemId?: string;
495
548
  };
496
549
  /** The connected-account PaymentIntent for a package purchase. Confirm it with
497
550
  * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.
@@ -529,6 +582,8 @@ type PackagePreviewArgs = {
529
582
  quantity: number;
530
583
  }[];
531
584
  shareToken?: string;
585
+ /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */
586
+ flashSaleItemId?: string;
532
587
  };
533
588
  /** Server-computed itemized quote for a package order — base, optional add-ons,
534
589
  * tax lines, the selling Center's booking fee, and the authoritative grand
@@ -567,6 +622,8 @@ declare function previewPackage(client: BowlosClient, args: PackagePreviewArgs):
567
622
  type MembershipPreviewArgs = {
568
623
  templateId: string;
569
624
  shareToken?: string;
625
+ /** v0.32.0: reflect the flash sale price in the Review (one-time only). */
626
+ flashSaleItemId?: string;
570
627
  };
571
628
  /** Server-computed itemized quote for a one-time membership purchase — the dues,
572
629
  * the one-time setup (joining) fee, tax lines, the selling Center's booking fee,
@@ -600,6 +657,8 @@ type MembershipPurchaseArgs = {
600
657
  templateId: string;
601
658
  idempotencyKey?: string;
602
659
  shareToken?: string;
660
+ /** v0.32.0: redeem this flash-sale item at its sale price (one-time only). */
661
+ flashSaleItemId?: string;
603
662
  };
604
663
  /** The connected-account PaymentIntent for a one-time membership purchase.
605
664
  * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` + the
@@ -215,10 +215,52 @@ type BookingPreviewArgs = {
215
215
  * price plan, tax override, and Center fee override/inheritance. */
216
216
  eventOfferSlug?: string;
217
217
  };
218
+ /** One add-on line on a plan quote. A plan-included add-on (e.g. shoes on a
219
+ * "Thursday Special") is already dropped from this list — it won't appear. */
220
+ interface BookingQuoteAddonLine {
221
+ addonId: string;
222
+ addonName: string;
223
+ quantity: number;
224
+ unitPriceCents: number;
225
+ lineSubtotalCents: number;
226
+ rateMode?: string;
227
+ }
228
+ /** Per-plan price breakdown. Render THESE fields to itemize the order — do not
229
+ * reconstruct a base by subtracting tax/fee/add-ons from the total, and do not
230
+ * recompute the discount client-side. `preDiscountTotalCents` is the original
231
+ * (base + add-ons, before discount); `appliedDiscount` is present only when a
232
+ * discount applied; `finalCents` is the subtotal after discount, BEFORE tax +
233
+ * fee. The all-in charge is `totalCentsPerPlan[samePlanId].totalCents`. */
234
+ interface BookingQuotePlan {
235
+ pricePlanId: string;
236
+ pricePlanName: string;
237
+ pricePlanDescription?: string;
238
+ baseSubtotalCents: number;
239
+ addonSubtotalCents: number;
240
+ addonLineItems: BookingQuoteAddonLine[];
241
+ preDiscountTotalCents: number;
242
+ /** Present only when a discount applied. `.label` is display text
243
+ * ("Online booking discount"); `.amountCents` is the amount to subtract. */
244
+ appliedDiscount?: {
245
+ amountCents: number;
246
+ label: string;
247
+ source: string;
248
+ };
249
+ /** Subtotal after discount, before tax + fee. */
250
+ finalCents: number;
251
+ /** True when this plan/special bundles shoes — hide the shoe add-on selector
252
+ * and show a "Shoes included" line instead of a priced shoe row. */
253
+ shoesIncluded?: boolean;
254
+ }
218
255
  /** The price quote. Headline fields are typed; the engine's full breakdown
219
- * (line items, discounts, tax, credit) is passed through. */
256
+ * (line items, discounts, tax, credit) is passed through. Join `plans`,
257
+ * `taxLinesPerPlan`, and `totalCentsPerPlan` by `pricePlanId` — never index
258
+ * `[0]` blindly when more than one plan can be returned. */
220
259
  interface BookingQuote {
221
260
  reservationFee: Record<string, unknown> | null;
261
+ /** Per-plan breakdown (name, original price, applied discount, line items).
262
+ * Optional for back-compat with older cores that didn't type it. */
263
+ plans?: BookingQuotePlan[];
222
264
  totalCentsPerPlan: Array<{
223
265
  pricePlanId: string;
224
266
  totalCents: number;
@@ -357,6 +399,9 @@ type GameCardPurchaseArgs = {
357
399
  templateId: string;
358
400
  idempotencyKey?: string;
359
401
  shareToken?: string;
402
+ /** v0.32.0: when set, the buy redeems this flash-sale item at its sale price
403
+ * (the flash sale must be Live; the server validates the item matches). */
404
+ flashSaleItemId?: string;
360
405
  };
361
406
  /** The connected-account PaymentIntent for a game-pass purchase. Confirm it with
362
407
  * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.
@@ -392,6 +437,8 @@ declare function getGameCardStatus(client: BowlosClient, refToken: string): Prom
392
437
  type GameCardPreviewArgs = {
393
438
  templateId: string;
394
439
  shareToken?: string;
440
+ /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */
441
+ flashSaleItemId?: string;
395
442
  };
396
443
  /** Server-computed itemized quote for a game-pass purchase — the base price,
397
444
  * tax lines, the selling Center's booking fee, and the authoritative grand
@@ -419,6 +466,8 @@ declare function previewGameCard(client: BowlosClient, args: GameCardPreviewArgs
419
466
  type EventTicketPreviewArgs = {
420
467
  eventOfferId: string;
421
468
  quantity: number;
469
+ /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */
470
+ flashSaleItemId?: string;
422
471
  };
423
472
  interface EventTicketPreviewResult {
424
473
  eventName: string;
@@ -447,6 +496,8 @@ type EventTicketPurchaseArgs = {
447
496
  eventOfferId: string;
448
497
  quantity: number;
449
498
  idempotencyKey?: string;
499
+ /** v0.32.0: redeem this flash-sale item at its sale price. */
500
+ flashSaleItemId?: string;
450
501
  };
451
502
  /** The connected-account PaymentIntent for a ticket-mode event purchase.
452
503
  * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` +
@@ -492,6 +543,8 @@ type PackagePurchaseArgs = {
492
543
  scheduledStartMinute: number;
493
544
  idempotencyKey?: string;
494
545
  shareToken?: string;
546
+ /** v0.32.0: redeem this flash-sale item at its sale price. */
547
+ flashSaleItemId?: string;
495
548
  };
496
549
  /** The connected-account PaymentIntent for a package purchase. Confirm it with
497
550
  * `<BowlosPaymentForm>` — it carries `connectedAccountId` + the customer session.
@@ -529,6 +582,8 @@ type PackagePreviewArgs = {
529
582
  quantity: number;
530
583
  }[];
531
584
  shareToken?: string;
585
+ /** v0.32.0: reflect the flash sale price in the Review (same as the buy). */
586
+ flashSaleItemId?: string;
532
587
  };
533
588
  /** Server-computed itemized quote for a package order — base, optional add-ons,
534
589
  * tax lines, the selling Center's booking fee, and the authoritative grand
@@ -567,6 +622,8 @@ declare function previewPackage(client: BowlosClient, args: PackagePreviewArgs):
567
622
  type MembershipPreviewArgs = {
568
623
  templateId: string;
569
624
  shareToken?: string;
625
+ /** v0.32.0: reflect the flash sale price in the Review (one-time only). */
626
+ flashSaleItemId?: string;
570
627
  };
571
628
  /** Server-computed itemized quote for a one-time membership purchase — the dues,
572
629
  * the one-time setup (joining) fee, tax lines, the selling Center's booking fee,
@@ -600,6 +657,8 @@ type MembershipPurchaseArgs = {
600
657
  templateId: string;
601
658
  idempotencyKey?: string;
602
659
  shareToken?: string;
660
+ /** v0.32.0: redeem this flash-sale item at its sale price (one-time only). */
661
+ flashSaleItemId?: string;
603
662
  };
604
663
  /** The connected-account PaymentIntent for a one-time membership purchase.
605
664
  * Confirm it with `<BowlosPaymentForm>` — it carries `connectedAccountId` + the
package/dist/index.cjs CHANGED
@@ -809,6 +809,31 @@ function listRetailPricing(client, args) {
809
809
  }
810
810
 
811
811
  // src/packages.ts
812
+ function splitPackageAddons(addons) {
813
+ const included = [];
814
+ const optional = [];
815
+ for (const a of addons ?? []) {
816
+ (a.mode === "optional" ? optional : included).push(a);
817
+ }
818
+ return { included, optional };
819
+ }
820
+ function toOptionalAddonsInput(addons, quantities) {
821
+ const optionalById = new Map(
822
+ (addons ?? []).filter((a) => a.mode === "optional").map((a) => [a.id, a])
823
+ );
824
+ const out = [];
825
+ for (const [addonId, raw] of Object.entries(quantities ?? {})) {
826
+ const a = optionalById.get(addonId);
827
+ if (!a) continue;
828
+ let q = Math.floor(Number(raw));
829
+ if (!Number.isFinite(q) || q <= 0) continue;
830
+ if (typeof a.maxOptionalQuantity === "number" && a.maxOptionalQuantity > 0) {
831
+ q = Math.min(q, a.maxOptionalQuantity);
832
+ }
833
+ out.push({ addonId, quantity: q });
834
+ }
835
+ return out;
836
+ }
812
837
  function usesPerWeekdayStartTimes(pkg) {
813
838
  return !!pkg.startTimesByWeekday && pkg.startTimesByWeekday.length > 0;
814
839
  }
@@ -897,6 +922,8 @@ exports.previewPackageOrderCancellation = previewPackageOrderCancellation;
897
922
  exports.previewReservationCancellation = previewReservationCancellation;
898
923
  exports.resolvePackageStartTimesForWeekday = resolvePackageStartTimesForWeekday;
899
924
  exports.runDoctor = runDoctor;
925
+ exports.splitPackageAddons = splitPackageAddons;
926
+ exports.toOptionalAddonsInput = toOptionalAddonsInput;
900
927
  exports.usesPerWeekdayStartTimes = usesPerWeekdayStartTimes;
901
928
  exports.weekdayForDateISO = weekdayForDateISO;
902
929
  //# sourceMappingURL=index.cjs.map