@curless/hotel-storefront 0.79.0 → 0.79.1

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.
package/dist/tools.js CHANGED
@@ -2707,6 +2707,7 @@ const quoteForCard = (quote, groupOf) => ({
2707
2707
  // stepper read 3 and sent 3 ± 1 as the new count (2026-09-28 audit).
2708
2708
  ...(l.ordered !== undefined ? { ordered: l.ordered } : {}),
2709
2709
  unit: formatMoney(l.unit),
2710
+ ...(l.roomCharges ? { roomCharges: formatMoney(l.roomCharges) } : {}),
2710
2711
  ...(l.publicUnit ? { publicUnit: formatMoney(l.publicUnit) } : {}),
2711
2712
  total: formatMoney(l.total),
2712
2713
  // The line with its taxes in, where the backend knows them per line: what the
@@ -3210,7 +3211,14 @@ const offerCount = (rooms) => {
3210
3211
  /** What one room costs, as the text says it: nights, or the hours of a room by the hour. */
3211
3212
  const priceWords = (r, noCards) => r.hourly
3212
3213
  ? `${formatMoney(r.stayTotal)} for ${r.hourly.hours} hours incl. taxes and fees, starting between ${r.hourly.earliestStart} and ${r.hourly.latestStart} today and out by ${r.hourly.latestEnd}`
3213
- : `${formatMoney(r.nightly)} ${nightWords(noCards, nightlyIncludesTaxes(r))}, ${wholeStayWords(r)}`;
3214
+ : `${nightlyPart(r, noCards)}, ${wholeStayWords(r)}`;
3215
+ /**
3216
+ * A night - or, where the night is a rounded average (`Room.roomCharges`, 0.79.1), the stay's room
3217
+ * charges before taxes, so that charges + taxes = the total the text gives beside it.
3218
+ */
3219
+ const nightlyPart = (r, noCards) => r.roomCharges
3220
+ ? `${formatMoney(r.roomCharges)} room charges for ${r.nights} nights before taxes (${formatMoney(r.taxesAndFees)} tax and fees on top)`
3221
+ : `${formatMoney(r.nightly)} ${nightWords(noCards, nightlyIncludesTaxes(r))}`;
3214
3222
  /**
3215
3223
  * The whole stay, as the text says it - or that the group has quoted none.
3216
3224
  *
@@ -3384,7 +3392,7 @@ const roomFactsWords = (r, rate = false) => {
3384
3392
  /** The cheapest price a rate quotes, as the text says it: "from" a night, or the hours of a block. */
3385
3393
  const fromWords = (r, noCards) => r.hourly
3386
3394
  ? `${formatMoney(r.stayTotal)} for ${r.hourly.hours} hours incl. taxes and fees`
3387
- : `${formatMoney(r.nightly)} ${nightWords(noCards, nightlyIncludesTaxes(r))}, ${wholeStayWords(r)}`;
3395
+ : `${nightlyPart(r, noCards)}, ${wholeStayWords(r)}`;
3388
3396
  /**
3389
3397
  * A hotel's rooms for the nights, one line per ROOM TYPE.
3390
3398
  *
@@ -3531,9 +3539,11 @@ readOnly = false) => {
3531
3539
  ? `${formatMoney(multiplyMoney(r.stayTotal, roomsWanted))} for ${roomsWanted} rooms${mixed ? ' for the stay' : ''}`
3532
3540
  : `${formatMoney(r.stayTotal)}${mixed ? ' for the stay' : ''}`;
3533
3541
  // ⚠️ "BEFORE TAXES" ONLY WHERE IT IS SO (0.55.3): see `nightlyIncludesTaxes`.
3534
- const nightly = (r) => r.hourly
3535
- ? ''
3536
- : `${formatMoney(r.nightly)} ${nightWords(true, nightlyIncludesTaxes(r))}${many ? ', per room' : ''}`;
3542
+ //
3543
+ // ⚠️ NOT TWICE (0.79.1, Manus 11-19, Otaless's River View Suite: 「可住3人。每晚 $208。」 and, a
3544
+ // line under it, 「可住3人 · 每晚 $208」): where the price under the choice IS a night's
3545
+ // (`stayTotalUnquoted`) the sentence does not say the night as well.
3546
+ const nightly = (r) => r.hourly || r.stayTotalUnquoted ? '' : `${nightlyPart(r, true)}${many ? ', per room' : ''}`;
3537
3547
  const more = (n) => n ? `${n} more ${n === 1 ? 'rate' : 'rates'} on this room type` : '';
3538
3548
  // Breakfast and terms are said for most as "unless one says otherwise"; the
3539
3549
  // rest only where every one is the same.
@@ -3554,7 +3564,6 @@ readOnly = false) => {
3554
3564
  cheapest: setsApart(rows.map(({ r }) => !r.hourly && basis(r) === lowest)),
3555
3565
  breakfast: setsApart(rows.map(({ r }) => facetsOf(r).breakfast)),
3556
3566
  free: setsApart(rows.map(({ r }) => facetsOf(r).freeCancellation)),
3557
- family: setsApart(rows.map(({ r }) => r.sleeps >= FAMILY_SLEEPS)),
3558
3567
  };
3559
3568
  // ⚠️ A ROOM'S OWN FACTS IN WORDS (0.77.3, Manus 11-19: each line had a name, beds and a price):
3560
3569
  // where the rooms carry what only Huazhu's record adds (Wi-Fi, an extra bed) every type says
@@ -3590,7 +3599,8 @@ readOnly = false) => {
3590
3599
  apart.cheapest && basis(r) === lowest ? 'Lowest price' : '',
3591
3600
  apart.breakfast && facetsOf(r).breakfast ? 'Breakfast' : '',
3592
3601
  apart.free && facetsOf(r).freeCancellation ? 'Free cancellation' : '',
3593
- apart.family && r.sleeps >= FAMILY_SLEEPS ? `Sleeps ${r.sleeps}` : '',
3602
+ // ⚠️ NO "Sleeps N" TAG (0.79.1): the sentence above already says it for every room that
3603
+ // sleeps that many - the tag said it a second time, a line under.
3594
3604
  ].filter(Boolean),
3595
3605
  price: price(r),
3596
3606
  });
@@ -4007,6 +4017,7 @@ const payByWords = (p) => p.payByLocal ?? clockWords(p.payBy);
4007
4017
  */
4008
4018
  const BOOKING_REFUSALS = new Set([
4009
4019
  'sign-in',
4020
+ 'link-redo',
4010
4021
  'signed-out',
4011
4022
  'session-expired',
4012
4023
  'guest',
@@ -4024,7 +4035,7 @@ const BOOKING_REFUSALS = new Set([
4024
4035
  'price-changed',
4025
4036
  ]);
4026
4037
  /** The three that mean "sign in at this group": they carry the groups (`groups`, provider codes). */
4027
- const SIGN_IN_REFUSALS = new Set(['sign-in', 'signed-out', 'session-expired']);
4038
+ const SIGN_IN_REFUSALS = new Set(['sign-in', 'link-redo', 'signed-out', 'session-expired']);
4028
4039
  /**
4029
4040
  * The answer to a booking refusal, or undefined when `err` is not one.
4030
4041
  *
@@ -4033,8 +4044,14 @@ const SIGN_IN_REFUSALS = new Set(['sign-in', 'signed-out', 'session-expired']);
4033
4044
  * where the deployment has one (`ToolDeps.groupSignIn`), else its sign-in tool.
4034
4045
  */
4035
4046
  const refusalAnswer = (deps, key, err) => {
4036
- const e = err;
4037
- if (!(e instanceof Error) || typeof e.code !== 'string' || !BOOKING_REFUSALS.has(e.code))
4047
+ const raw = err;
4048
+ if (!(raw instanceof Error) || typeof raw.code !== 'string')
4049
+ return undefined;
4050
+ // 0.79.1: a `sign-in` the group's 409 asked for (`redo`) is said as its own refusal.
4051
+ const e = raw.code === 'sign-in' && raw.redo === true
4052
+ ? Object.assign(new Error(raw.message), { code: 'link-redo', groups: raw.groups })
4053
+ : { ...raw, message: raw.message, code: raw.code };
4054
+ if (!BOOKING_REFUSALS.has(e.code))
4038
4055
  return undefined;
4039
4056
  const codes = SIGN_IN_REFUSALS.has(e.code) && Array.isArray(e.groups)
4040
4057
  ? [...new Set(e.groups.filter((g) => typeof g === 'string' && !!g))]
@@ -6658,7 +6675,7 @@ const bookingAnswer = async (deps, t, ctx, key, store, args, inTrip, lines, show
6658
6675
  // refused for that alone says (`refusalAnswer`).
6659
6676
  const signInFor = (f) => {
6660
6677
  const how = deps.groupSignIn;
6661
- if (f.code === 'link-first' && how?.linkTool)
6678
+ if ((f.code === 'link-first' || f.code === 'link-redo') && how?.linkTool)
6662
6679
  return (f.groups ?? [])
6663
6680
  .map((code) => {
6664
6681
  const name = deps.backend.suppliers?.().find((x) => x.id === code)?.name ?? code;
@@ -8068,6 +8085,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
8068
8085
  ...(r.terms !== undefined ? {} : { refundable }),
8069
8086
  facets: facetsOf({ ...r, roomsLeft, refundable }),
8070
8087
  nightly: formatMoney(r.nightly),
8088
+ // The room charges for the stay, where `nightly` is a rounded average (0.79.1).
8089
+ ...(r.roomCharges ? { roomCharges: formatMoney(r.roomCharges) } : {}),
8071
8090
  // ⚠️ NO STAY TOTAL WHERE IT IS OURS (总线程 11-13, `Room.stayTotalUnquoted`):
8072
8091
  // absent here, so neither the card nor the model reads nights times a night
8073
8092
  // as a price the group gave for the stay.