@bowlos/reservations 0.32.0 → 0.35.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 (37) hide show
  1. package/HEADLESS.md +122 -21
  2. package/README.md +29 -0
  3. package/dist/{account-B5i2ddbT.d.ts → account-BJ5UjC0r.d.ts} +1 -1
  4. package/dist/{account-bfaIAO_T.d.cts → account-QoFg8-i1.d.cts} +1 -1
  5. package/dist/{catalog-Dq8gpdAA.d.ts → catalog-CGitz1PG.d.ts} +1 -1
  6. package/dist/{catalog-BtvuX49Y.d.cts → catalog-p9cwB6Qv.d.cts} +1 -1
  7. package/dist/{chunk-BFSMRBWB.js → chunk-MMSVM3QS.js} +3 -3
  8. package/dist/{chunk-BFSMRBWB.js.map → chunk-MMSVM3QS.js.map} +1 -1
  9. package/dist/{chunk-EQH5HDYQ.js → chunk-SMPDCDMB.js} +3 -3
  10. package/dist/chunk-SMPDCDMB.js.map +1 -0
  11. package/dist/{chunk-MJHRMLJO.js → chunk-UN5E6UEZ.js} +2 -2
  12. package/dist/{chunk-MJHRMLJO.js.map → chunk-UN5E6UEZ.js.map} +1 -1
  13. package/dist/components.cjs +68 -22
  14. package/dist/components.cjs.map +1 -1
  15. package/dist/components.d.cts +4 -4
  16. package/dist/components.d.ts +4 -4
  17. package/dist/components.js +70 -24
  18. package/dist/components.js.map +1 -1
  19. package/dist/{data-qGBxYRJB.d.cts → data-qw8P3JW3.d.cts} +65 -3
  20. package/dist/{data-qGBxYRJB.d.ts → data-qw8P3JW3.d.ts} +65 -3
  21. package/dist/index.cjs +28 -1
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +54 -5
  24. package/dist/index.d.ts +54 -5
  25. package/dist/index.js +30 -5
  26. package/dist/index.js.map +1 -1
  27. package/dist/payments.d.cts +1 -1
  28. package/dist/payments.d.ts +1 -1
  29. package/dist/{react-9kBVKWRt.d.ts → react-C2V1kXnO.d.ts} +2 -2
  30. package/dist/{react--xfZz9Y4.d.cts → react-DtncBQ3b.d.cts} +2 -2
  31. package/dist/react.cjs.map +1 -1
  32. package/dist/react.d.cts +6 -6
  33. package/dist/react.d.ts +6 -6
  34. package/dist/react.js +3 -3
  35. package/package.json +1 -1
  36. package/templates/center-site/package.json +1 -1
  37. package/dist/chunk-EQH5HDYQ.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 = {
@@ -215,10 +223,52 @@ type BookingPreviewArgs = {
215
223
  * price plan, tax override, and Center fee override/inheritance. */
216
224
  eventOfferSlug?: string;
217
225
  };
226
+ /** One add-on line on a plan quote. A plan-included add-on (e.g. shoes on a
227
+ * "Thursday Special") is already dropped from this list — it won't appear. */
228
+ interface BookingQuoteAddonLine {
229
+ addonId: string;
230
+ addonName: string;
231
+ quantity: number;
232
+ unitPriceCents: number;
233
+ lineSubtotalCents: number;
234
+ rateMode?: string;
235
+ }
236
+ /** Per-plan price breakdown. Render THESE fields to itemize the order — do not
237
+ * reconstruct a base by subtracting tax/fee/add-ons from the total, and do not
238
+ * recompute the discount client-side. `preDiscountTotalCents` is the original
239
+ * (base + add-ons, before discount); `appliedDiscount` is present only when a
240
+ * discount applied; `finalCents` is the subtotal after discount, BEFORE tax +
241
+ * fee. The all-in charge is `totalCentsPerPlan[samePlanId].totalCents`. */
242
+ interface BookingQuotePlan {
243
+ pricePlanId: string;
244
+ pricePlanName: string;
245
+ pricePlanDescription?: string;
246
+ baseSubtotalCents: number;
247
+ addonSubtotalCents: number;
248
+ addonLineItems: BookingQuoteAddonLine[];
249
+ preDiscountTotalCents: number;
250
+ /** Present only when a discount applied. `.label` is display text
251
+ * ("Online booking discount"); `.amountCents` is the amount to subtract. */
252
+ appliedDiscount?: {
253
+ amountCents: number;
254
+ label: string;
255
+ source: string;
256
+ };
257
+ /** Subtotal after discount, before tax + fee. */
258
+ finalCents: number;
259
+ /** True when this plan/special bundles shoes — hide the shoe add-on selector
260
+ * and show a "Shoes included" line instead of a priced shoe row. */
261
+ shoesIncluded?: boolean;
262
+ }
218
263
  /** The price quote. Headline fields are typed; the engine's full breakdown
219
- * (line items, discounts, tax, credit) is passed through. */
264
+ * (line items, discounts, tax, credit) is passed through. Join `plans`,
265
+ * `taxLinesPerPlan`, and `totalCentsPerPlan` by `pricePlanId` — never index
266
+ * `[0]` blindly when more than one plan can be returned. */
220
267
  interface BookingQuote {
221
268
  reservationFee: Record<string, unknown> | null;
269
+ /** Per-plan breakdown (name, original price, applied discount, line items).
270
+ * Optional for back-compat with older cores that didn't type it. */
271
+ plans?: BookingQuotePlan[];
222
272
  totalCentsPerPlan: Array<{
223
273
  pricePlanId: string;
224
274
  totalCents: number;
@@ -235,9 +285,18 @@ interface BookingQuote {
235
285
  }>;
236
286
  taxTotalCents: number;
237
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
+ };
238
297
  [key: string]: unknown;
239
298
  }
240
- /** Free units for a product/date/time window (anonymous). */
299
+ /** Available (unoccupied) units for a product/date/time window (anonymous). */
241
300
  declare function checkAvailability(client: BowlosClient, args: AvailabilityArgs): Promise<AvailabilityResult>;
242
301
  /** Authoritative price quote for the chosen inputs. Anonymous by default
243
302
  * (the center's standard online price). Pass `{ auth: true }` when the
@@ -267,7 +326,10 @@ type StartTimesArgs = {
267
326
  * within operating hours, past the booking buffer, and backed by a real price
268
327
  * plan (same pricing engine the quote uses). Anonymous-callable. */
269
328
  declare function listStartTimes(client: BowlosClient, args: StartTimesArgs): Promise<number[]>;
270
- /** 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". */
271
333
  declare function availableUnitCount(availability: AvailabilityResult): number;
272
334
  /** Customer identity for a booking (collected in the booking form; the server
273
335
  * links/creates the customer per the booking-flow-only signup rule). */
@@ -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 = {
@@ -215,10 +223,52 @@ type BookingPreviewArgs = {
215
223
  * price plan, tax override, and Center fee override/inheritance. */
216
224
  eventOfferSlug?: string;
217
225
  };
226
+ /** One add-on line on a plan quote. A plan-included add-on (e.g. shoes on a
227
+ * "Thursday Special") is already dropped from this list — it won't appear. */
228
+ interface BookingQuoteAddonLine {
229
+ addonId: string;
230
+ addonName: string;
231
+ quantity: number;
232
+ unitPriceCents: number;
233
+ lineSubtotalCents: number;
234
+ rateMode?: string;
235
+ }
236
+ /** Per-plan price breakdown. Render THESE fields to itemize the order — do not
237
+ * reconstruct a base by subtracting tax/fee/add-ons from the total, and do not
238
+ * recompute the discount client-side. `preDiscountTotalCents` is the original
239
+ * (base + add-ons, before discount); `appliedDiscount` is present only when a
240
+ * discount applied; `finalCents` is the subtotal after discount, BEFORE tax +
241
+ * fee. The all-in charge is `totalCentsPerPlan[samePlanId].totalCents`. */
242
+ interface BookingQuotePlan {
243
+ pricePlanId: string;
244
+ pricePlanName: string;
245
+ pricePlanDescription?: string;
246
+ baseSubtotalCents: number;
247
+ addonSubtotalCents: number;
248
+ addonLineItems: BookingQuoteAddonLine[];
249
+ preDiscountTotalCents: number;
250
+ /** Present only when a discount applied. `.label` is display text
251
+ * ("Online booking discount"); `.amountCents` is the amount to subtract. */
252
+ appliedDiscount?: {
253
+ amountCents: number;
254
+ label: string;
255
+ source: string;
256
+ };
257
+ /** Subtotal after discount, before tax + fee. */
258
+ finalCents: number;
259
+ /** True when this plan/special bundles shoes — hide the shoe add-on selector
260
+ * and show a "Shoes included" line instead of a priced shoe row. */
261
+ shoesIncluded?: boolean;
262
+ }
218
263
  /** The price quote. Headline fields are typed; the engine's full breakdown
219
- * (line items, discounts, tax, credit) is passed through. */
264
+ * (line items, discounts, tax, credit) is passed through. Join `plans`,
265
+ * `taxLinesPerPlan`, and `totalCentsPerPlan` by `pricePlanId` — never index
266
+ * `[0]` blindly when more than one plan can be returned. */
220
267
  interface BookingQuote {
221
268
  reservationFee: Record<string, unknown> | null;
269
+ /** Per-plan breakdown (name, original price, applied discount, line items).
270
+ * Optional for back-compat with older cores that didn't type it. */
271
+ plans?: BookingQuotePlan[];
222
272
  totalCentsPerPlan: Array<{
223
273
  pricePlanId: string;
224
274
  totalCents: number;
@@ -235,9 +285,18 @@ interface BookingQuote {
235
285
  }>;
236
286
  taxTotalCents: number;
237
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
+ };
238
297
  [key: string]: unknown;
239
298
  }
240
- /** Free units for a product/date/time window (anonymous). */
299
+ /** Available (unoccupied) units for a product/date/time window (anonymous). */
241
300
  declare function checkAvailability(client: BowlosClient, args: AvailabilityArgs): Promise<AvailabilityResult>;
242
301
  /** Authoritative price quote for the chosen inputs. Anonymous by default
243
302
  * (the center's standard online price). Pass `{ auth: true }` when the
@@ -267,7 +326,10 @@ type StartTimesArgs = {
267
326
  * within operating hours, past the booking buffer, and backed by a real price
268
327
  * plan (same pricing engine the quote uses). Anonymous-callable. */
269
328
  declare function listStartTimes(client: BowlosClient, args: StartTimesArgs): Promise<number[]>;
270
- /** 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". */
271
333
  declare function availableUnitCount(availability: AvailabilityResult): number;
272
334
  /** Customer identity for a booking (collected in the booking form; the server
273
335
  * links/creates the customer per the booking-flow-only signup rule). */
package/dist/index.cjs CHANGED
@@ -323,7 +323,7 @@ function createBowlosClient(config) {
323
323
  return new BowlosClient(config);
324
324
  }
325
325
 
326
- // ../shared/src/inquiry.ts
326
+ // ../../../../../Users/bosummers/conductor/workspaces/bowlos/budapest/packages/shared/src/inquiry.ts
327
327
  var INQUIRY_FORMS = {
328
328
  contact: {
329
329
  label: "Contact",
@@ -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