@bowlos/reservations 0.32.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 +108 -20
  2. package/README.md +20 -0
  3. package/dist/{account-B5i2ddbT.d.ts → account-CsCusw5Z.d.ts} +1 -1
  4. package/dist/{account-bfaIAO_T.d.cts → account-Di8nktqp.d.cts} +1 -1
  5. package/dist/{catalog-Dq8gpdAA.d.ts → catalog-DT-ePirK.d.ts} +1 -1
  6. package/dist/{catalog-BtvuX49Y.d.cts → catalog-DdvLcOrs.d.cts} +1 -1
  7. package/dist/{chunk-BFSMRBWB.js → chunk-CAXGTKJQ.js} +3 -3
  8. package/dist/{chunk-BFSMRBWB.js.map → chunk-CAXGTKJQ.js.map} +1 -1
  9. package/dist/{chunk-MJHRMLJO.js → chunk-GIAJQPMM.js} +2 -2
  10. package/dist/{chunk-MJHRMLJO.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-qGBxYRJB.d.cts → data-BaHVz6fa.d.cts} +43 -1
  18. package/dist/{data-qGBxYRJB.d.ts → data-BaHVz6fa.d.ts} +43 -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-9kBVKWRt.d.ts → react-DImwA9C9.d.ts} +2 -2
  28. package/dist/{react--xfZz9Y4.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;
@@ -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;
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