@curless/hotel-storefront 0.74.0 → 0.74.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.
@@ -793,6 +793,12 @@ export const createOtalessBookings = (deps) => {
793
793
  counts.initRefused += 1;
794
794
  log(`[otaless] initialize for ${group} with the member's token was refused (code ${err.backendCode}) - questions, 11-10 evening`);
795
795
  }
796
+ // 0.74.1 (总线程's review of 0.74.0, P3): the account's sign-in over is said as that -
797
+ // and the group not linked as that - never as the group not taking the booking.
798
+ if (isCode(err, NOT_SIGNED_IN))
799
+ throw signedOut(acct);
800
+ if (unlinkedSaid(err))
801
+ throw linkFirst(acct, 'initialize said so in its own words');
796
802
  throw err;
797
803
  }
798
804
  const id = text(sent.data?.mcpSessionId) ?? sent.session;
@@ -866,6 +872,9 @@ export const createOtalessBookings = (deps) => {
866
872
  */
867
873
  const signedOut = (acct) => {
868
874
  sessions.delete(sessionKey(acct));
875
+ // ⚠️ ENDED HERE TOO (0.74.1, 总线程's review of 0.74.0, P2-2): kept signed in with a token
876
+ // the backend refuses, the guest told to sign in again was answered "already signed in".
877
+ deps.auth?.signedOut?.(acct.key);
869
878
  return signInRefusal('signed-out', `The guest's sign-in to their ${deps.brand} account is over, so nothing was done - ask them to sign in again.`, []);
870
879
  };
871
880
  // ── an order, as a booking ────────────────────────────────────────────────
@@ -1148,7 +1157,7 @@ export const createOtalessBookings = (deps) => {
1148
1157
  */
1149
1158
  const termsFrom8 = (a, w) => {
1150
1159
  const g = deps.groupOf(a.group);
1151
- const guest = [a.guest.name, a.guest.email, a.guest.phone];
1160
+ const guest = [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken];
1152
1161
  const note = text(w.summary ?? undefined);
1153
1162
  if (note)
1154
1163
  log(`[otaless] booking at ${a.group}: the summary of its terms, kept to this log: "${summaryForLog(note, guest)}"`);
@@ -1420,7 +1429,7 @@ export const createOtalessBookings = (deps) => {
1420
1429
  r.stay.checkIn === a.stay.checkIn &&
1421
1430
  r.stay.checkOut === a.stay.checkOut));
1422
1431
  const untouched = (a, id, how) => {
1423
- const guest = [a.guest.name, a.guest.email, a.guest.phone];
1432
+ const guest = [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken];
1424
1433
  log(`[otaless] booking at ${a.group}: 8 ${how} naming order ${forTheLog(id, guest)}, one already kept here - not touched (not cancelled, overwritten or claimed); said as a refusal`);
1425
1434
  return {
1426
1435
  failed: failedStay(a, `${deps.groupOf(a.group).name} did not take the booking, so nothing was booked or charged.`),
@@ -1442,6 +1451,8 @@ export const createOtalessBookings = (deps) => {
1442
1451
  a.guest.name,
1443
1452
  a.guest.email,
1444
1453
  a.guest.phone,
1454
+ // ⚠️ AND STEP 3's TOKEN (0.74.1): this line goes to the log as it is.
1455
+ a.confirmToken,
1445
1456
  ]),
1446
1457
  };
1447
1458
  };
@@ -1463,7 +1474,7 @@ export const createOtalessBookings = (deps) => {
1463
1474
  const r = recordOf(a, pairs, `pending:${randomBytes(8).toString('hex')}`, '', 'unconfirmed');
1464
1475
  r.refusedOrder = ref;
1465
1476
  put(r);
1466
- const guest = [a.guest.name, a.guest.email, a.guest.phone];
1477
+ const guest = [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken];
1467
1478
  const said = `booking at ${a.group} refused "${ref.said}" with order ${forTheLog(ref.id, guest)} in its answer`;
1468
1479
  let rows;
1469
1480
  try {
@@ -1546,7 +1557,7 @@ export const createOtalessBookings = (deps) => {
1546
1557
  // number. Never shown to the guest, never in what the model reads (questions #75).
1547
1558
  const note = text(w?.summary ?? undefined);
1548
1559
  if (note)
1549
- log(`[otaless] booking at ${a.group}: 8's summary, kept to this log: "${summaryForLog(note, [a.guest.name, a.guest.email, a.guest.phone])}"`);
1560
+ log(`[otaless] booking at ${a.group}: 8's summary, kept to this log: "${summaryForLog(note, [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken])}"`);
1550
1561
  const status = String(w?.status ?? '')
1551
1562
  .trim()
1552
1563
  .toUpperCase();
@@ -1555,7 +1566,7 @@ export const createOtalessBookings = (deps) => {
1555
1566
  const err = text(w?.errorMessage ?? undefined);
1556
1567
  if (!w || w.success === false || status === 'FAILED' || err) {
1557
1568
  if (err)
1558
- log(`[otaless] booking at ${a.group} refused: "${forTheLog(err, [a.guest.name, a.guest.email, a.guest.phone])}"`);
1569
+ log(`[otaless] booking at ${a.group} refused: "${forTheLog(err, [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken])}"`);
1559
1570
  const ref = w ? refusalOf(a, w, err ?? status) : undefined;
1560
1571
  if (ref)
1561
1572
  return refusedWithOrder(a, ref, pairs);
@@ -1911,7 +1922,7 @@ export const createOtalessBookings = (deps) => {
1911
1922
  .trim()
1912
1923
  .toUpperCase();
1913
1924
  // The guest's own details never on the log (总线程's re-review of 0.68.1, 2).
1914
- const guest = [a.guest.name, a.guest.email, a.guest.phone];
1925
+ const guest = [a.guest.name, a.guest.email, a.guest.phone, a.confirmToken];
1915
1926
  log(`[otaless] booking at ${a.group}: 8 refused "${forTheLog(String(msg), guest)}" with order ${forTheLog(id, guest)} in its answer - kept as that order, not sent again`);
1916
1927
  return {
1917
1928
  ...order,
@@ -1976,12 +1987,14 @@ export const createOtalessBookings = (deps) => {
1976
1987
  : failedStay(a, `${g.name} did not price it again just now, so nothing was booked.`, 'unreachable'),
1977
1988
  };
1978
1989
  if (err instanceof OtalessBusy)
1979
- return { failed: limited(a, g.name) };
1980
- // ⚠️ THE BACKEND'S OWN WORDS FOR A GROUP NOT LINKED (0.74.0, robin 11-17): refused, so
1981
- // nothing was ordered - the guest links it and presses Book again. Any other refusal is
1982
- // "not booked" below, with the backend's words on the log (client.ts).
1983
- if (unlinkedSaid(err))
1984
- throw linkFirst(a.acct, 'its own words for a group not linked');
1990
+ return {
1991
+ failed:
1992
+ // ⚠️ AFTER THE GUEST'S YES, ITS TERMS ARE GONE (0.74.1, 总线程's review of 0.74.0,
1993
+ // P3): agreed once, they cannot be agreed again - Book again asks for new ones.
1994
+ a.groupTerms === 'agreed'
1995
+ ? failedStay(a, `Not sent to ${g.name}: too many requests just now, so nothing was booked - the guest presses Book again in a minute.`, 'limited')
1996
+ : limited(a, g.name),
1997
+ };
1985
1998
  // ⚠️ THE GROUP'S TERMS ASKED FOR, NOTHING AGREED - A 10014 IS NO ORDER (总线程's review
1986
1999
  // of 0.72.1, P2-1): 8 sent with `termsRequired: true` answers the terms and orders
1987
2000
  // nothing, so its repeat refused (10014) - Book pressed twice at Ascott, or asked again
@@ -2022,6 +2035,13 @@ export const createOtalessBookings = (deps) => {
2022
2035
  : undefined;
2023
2036
  if (ref)
2024
2037
  return refusedWithOrder(a, ref, pairs ?? { orig: a.total });
2038
+ // ⚠️ THE BACKEND'S OWN WORDS FOR A GROUP NOT LINKED (0.74.0, robin 11-17): refused, so
2039
+ // nothing was ordered - the guest links it and presses Book again. ⚠️ ONLY ONCE NO ORDER
2040
+ // IS NAMED IN THE REFUSAL (0.74.1, 总线程's review of 0.74.0, P2-1): one that names its
2041
+ // order was checked as that order just above - said as "not booked", it was booked twice.
2042
+ // Any other refusal is "not booked" below, with the backend's words on the log.
2043
+ if (unlinkedSaid(err))
2044
+ throw linkFirst(a.acct, 'its own words for a group not linked');
2025
2045
  if (err instanceof OtalessError)
2026
2046
  return {
2027
2047
  failed: failedStay(a, `${g.name} did not take the booking, so nothing was booked or charged.`),
@@ -2236,6 +2256,34 @@ export const createOtalessBookings = (deps) => {
2236
2256
  const booked = [];
2237
2257
  const terms = [];
2238
2258
  const reused = [];
2259
+ /**
2260
+ * ⚠️ ONE STAY REFUSED FOR A SIGN-IN OR A LINK IS THAT STAY'S ALONE (0.74.1, 总线程's review
2261
+ * of 0.74.0, P1): thrown, it took the stays booked before it out of the answer - the
2262
+ * guest read "nothing was booked", and Book again ordered them twice (an order CONFIRMED
2263
+ * with no payment page is not one `stayGuard` hands back). Kept as that stay's failure,
2264
+ * with its groups, beside what was booked; nothing booked at all, the refusal itself is
2265
+ * the answer, as before.
2266
+ */
2267
+ const stayRefusals = [];
2268
+ const placeStay = async (label, ask) => {
2269
+ try {
2270
+ return await place(ask);
2271
+ }
2272
+ catch (err) {
2273
+ const e = err;
2274
+ if (!(err instanceof Error) ||
2275
+ (e?.code !== 'sign-in' && e?.code !== 'signed-out' && e?.code !== 'session-expired') ||
2276
+ !Array.isArray(e.groups))
2277
+ throw err;
2278
+ stayRefusals.push(err);
2279
+ return {
2280
+ failed: {
2281
+ ...failedStay(label, err.message),
2282
+ ...(e.groups.length ? { groups: [...e.groups] } : {}),
2283
+ },
2284
+ };
2285
+ }
2286
+ };
2239
2287
  for (const line of q.lines) {
2240
2288
  if (line.kind !== 'room' || !line.stay || !line.roomRef)
2241
2289
  continue;
@@ -2300,7 +2348,12 @@ export const createOtalessBookings = (deps) => {
2300
2348
  if (needsTerms) {
2301
2349
  inFlight.add(lockKey);
2302
2350
  try {
2303
- const out = await place({ ...ask, agreed: '', roomTerms: agreed, groupTerms: 'ask' });
2351
+ const out = await placeStay(label, {
2352
+ ...ask,
2353
+ agreed: '',
2354
+ roomTerms: agreed,
2355
+ groupTerms: 'ask',
2356
+ });
2304
2357
  if (out.booked)
2305
2358
  booked.push(out.booked);
2306
2359
  if (out.failed)
@@ -2319,7 +2372,7 @@ export const createOtalessBookings = (deps) => {
2319
2372
  if (!agreed && deps.proceedWithoutGroupConfirm) {
2320
2373
  inFlight.add(lockKey);
2321
2374
  try {
2322
- const out = await place({
2375
+ const out = await placeStay(label, {
2323
2376
  ...ask,
2324
2377
  noTerms: true,
2325
2378
  ...(unsaid ? { groupTerms: 'ask' } : {}),
@@ -2339,6 +2392,9 @@ export const createOtalessBookings = (deps) => {
2339
2392
  // ⚠️ NOTHING IS ORDERED YET (§15.1): the terms first, for the guest to agree to.
2340
2393
  terms.push(termsBefore(ask, unsaid));
2341
2394
  }
2395
+ // Nothing booked, nothing waiting: the sign-in or link the backend asked for is the answer.
2396
+ if (stayRefusals[0] && !booked.length && !terms.length)
2397
+ throw stayRefusals[0];
2342
2398
  return {
2343
2399
  booked,
2344
2400
  failed,