@curless/hotel-storefront 0.67.0 → 0.67.2

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 (51) hide show
  1. package/dist/account/index.d.ts +4 -0
  2. package/dist/account/index.d.ts.map +1 -1
  3. package/dist/account/index.js +32 -18
  4. package/dist/account/index.js.map +1 -1
  5. package/dist/account/pages.d.ts +5 -1
  6. package/dist/account/pages.d.ts.map +1 -1
  7. package/dist/account/pages.js +47 -13
  8. package/dist/account/pages.js.map +1 -1
  9. package/dist/account/requests.d.ts +1 -1
  10. package/dist/account/requests.d.ts.map +1 -1
  11. package/dist/card.generated.d.ts +1 -1
  12. package/dist/card.generated.js +2 -2
  13. package/dist/card.generated.js.map +1 -1
  14. package/dist/config.d.ts +10 -0
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/config.js.map +1 -1
  17. package/dist/otaless/backend.d.ts +4 -0
  18. package/dist/otaless/backend.d.ts.map +1 -1
  19. package/dist/otaless/backend.js +31 -0
  20. package/dist/otaless/backend.js.map +1 -1
  21. package/dist/otaless/booking.d.ts +42 -1
  22. package/dist/otaless/booking.d.ts.map +1 -1
  23. package/dist/otaless/booking.js +130 -24
  24. package/dist/otaless/booking.js.map +1 -1
  25. package/dist/otaless/fake.d.ts +6 -0
  26. package/dist/otaless/fake.d.ts.map +1 -1
  27. package/dist/otaless/fake.js +6 -3
  28. package/dist/otaless/fake.js.map +1 -1
  29. package/dist/otaless/make.d.ts +6 -0
  30. package/dist/otaless/make.d.ts.map +1 -1
  31. package/dist/otaless/make.js +26 -1
  32. package/dist/otaless/make.js.map +1 -1
  33. package/dist/server.d.ts +3 -1
  34. package/dist/server.d.ts.map +1 -1
  35. package/dist/server.js +245 -15
  36. package/dist/server.js.map +1 -1
  37. package/dist/surface.d.ts +1 -1
  38. package/dist/surface.d.ts.map +1 -1
  39. package/dist/surface.js +1 -1
  40. package/dist/surface.js.map +1 -1
  41. package/dist/tools.d.ts +6 -0
  42. package/dist/tools.d.ts.map +1 -1
  43. package/dist/tools.js +77 -17
  44. package/dist/tools.js.map +1 -1
  45. package/dist/trip-ids.d.ts +27 -0
  46. package/dist/trip-ids.d.ts.map +1 -1
  47. package/dist/trip-ids.js +70 -0
  48. package/dist/trip-ids.js.map +1 -1
  49. package/dist/types.d.ts +23 -0
  50. package/dist/types.d.ts.map +1 -1
  51. package/package.json +1 -1
@@ -686,7 +686,8 @@ export const createOtalessBookings = (deps) => {
686
686
  quantity: r.rooms,
687
687
  unit: money(Math.round(r.quoted.minor / Math.max(1, n * r.rooms)), r.quoted.currency),
688
688
  total: r.quoted,
689
- terms: r.terms ?? '',
689
+ // Not agreed to: on the card's terms and the one-time page only (总线程's review of 0.67.0, 1).
690
+ terms: r.termsNew ? '' : (r.terms ?? ''),
690
691
  day: r.stay.checkIn,
691
692
  };
692
693
  const payment = paymentOf(r);
@@ -715,10 +716,18 @@ export const createOtalessBookings = (deps) => {
715
716
  };
716
717
  // Beside the type, for the words (0.63.2): why it is not known - and (11-11,
717
718
  // D) an order whose payment page waits for terms the group answered it with.
718
- return Object.assign(booking, r.unverifiable ? { unverifiable: true } : {}, r.needsPerson ? { needsPerson: r.needsPerson } : {}, r.held ? { termsChanged: true, termsUntil: r.held.until } : {},
719
+ return Object.assign(booking, r.unverifiable ? { unverifiable: true } : {}, r.needsPerson ? { needsPerson: r.needsPerson } : {}, r.held?.step === 'confirm'
720
+ ? { confirmAsked: true, termsUntil: r.held.until }
721
+ : r.held
722
+ ? { termsChanged: true, termsUntil: r.held.until }
723
+ : {},
719
724
  // With a person past its time and the guest told so: no longer holds the stay
720
725
  // back (总线程's review of 0.66.0, 6) - the words must not say it does.
721
- r.needsPerson && r.rebookable ? { rebookable: true } : {});
726
+ r.needsPerson && r.rebookable ? { rebookable: true } : {},
727
+ // Beside the type, for the words (酒店平台 0.67.1, robin 11-12): a step the
728
+ // group asked for with nothing to show - it may need the group to confirm
729
+ // it separately; and an order made with no terms to agree to.
730
+ r.stepUnsent ? { confirmUnseen: true } : {}, r.noTerms ? { noTermsGiven: true } : {});
722
731
  };
723
732
  const failedStay = (a, why, code) => ({
724
733
  hotelId: a.hotel.id,
@@ -731,6 +740,7 @@ export const createOtalessBookings = (deps) => {
731
740
  });
732
741
  const limited = (a, name) => failedStay(a, `Not sent to ${name}: too many requests just now - ask again in a minute.`, 'limited');
733
742
  const recordOf = (a, pairs, id, code, status) => ({
743
+ ...(a.noTerms ? { noTerms: true } : {}),
734
744
  id,
735
745
  code,
736
746
  group: a.group,
@@ -819,6 +829,14 @@ export const createOtalessBookings = (deps) => {
819
829
  key: a.acct.key,
820
830
  ask: { roomId: a.roomId, guest: a.guest },
821
831
  });
832
+ /** Where what a group asks to agree to or confirm is not what the guest was shown - or nothing. */
833
+ const stepOff = (asked, a, pairs) => asked.amountUnread ||
834
+ (asked.amount && !(same(asked.amount, pairs.orig) || same(asked.amount, pairs.usd)))
835
+ ? 'another amount'
836
+ : (asked.checkIn !== undefined && asked.checkIn !== a.stay.checkIn) ||
837
+ (asked.checkOut !== undefined && asked.checkOut !== a.stay.checkOut)
838
+ ? 'other nights'
839
+ : undefined;
822
840
  /**
823
841
  * 8 asked for a second step (`terms_required`, questions #66;
824
842
  * `confirm_required`, #68). ⚠️ NEVER AGREED OR CONFIRMED FOR THE GUEST (#52):
@@ -834,11 +852,9 @@ export const createOtalessBookings = (deps) => {
834
852
  const code = (step === 'terms' ? 'group-terms' : 'group-confirm');
835
853
  const asked = groupStepOf(step, data);
836
854
  if (asked && !a.groupStep) {
837
- const amountOff = asked.amountUnread ||
838
- (asked.amount && !(same(asked.amount, pairs.orig) || same(asked.amount, pairs.usd)));
839
- const nightsOff = (asked.checkIn !== undefined && asked.checkIn !== a.stay.checkIn) ||
840
- (asked.checkOut !== undefined && asked.checkOut !== a.stay.checkOut);
841
- if (amountOff || nightsOff) {
855
+ const off = stepOff(asked, a, pairs);
856
+ const amountOff = off === 'another amount';
857
+ if (off) {
842
858
  log(`[otaless] booking at ${a.group} answered ${what} for ${amountOff ? 'another amount' : 'other nights'} than the guest was shown - not shown, not booked`);
843
859
  return {
844
860
  failed: failedStay(a, `${g.name} asked for ${step === 'terms' ? 'its terms to be agreed to' : 'the booking to be confirmed'} at ${amountOff ? 'another amount' : 'other nights'} than the guest was shown, so nothing was booked or charged.`, code),
@@ -891,7 +907,9 @@ export const createOtalessBookings = (deps) => {
891
907
  * gone from memory (a restart), the order's own kept again until its time.
892
908
  */
893
909
  const termsOfHeld = (r, acct) => {
894
- if (!r.held || r.released || !r.terms || now() >= Date.parse(r.held.until))
910
+ const confirming = r.held?.step === 'confirm';
911
+ const shown = confirming ? r.confirmText : r.terms;
912
+ if (!r.held || r.released || !shown || now() >= Date.parse(r.held.until))
895
913
  return undefined;
896
914
  // Seen in this conversation: its time running out is cancelled with this sign-in.
897
915
  if (acct.owner === r.owner)
@@ -910,10 +928,10 @@ export const createOtalessBookings = (deps) => {
910
928
  stay: r.stay,
911
929
  rooms: r.rooms,
912
930
  total: r.quoted,
913
- text: r.terms,
931
+ text: shown,
914
932
  source: 'booking',
915
933
  more: true,
916
- changed: true,
934
+ ...(confirming ? { askedByGroup: 'confirm' } : { changed: true }),
917
935
  bookingId: r.id,
918
936
  confirmationCode: r.code || r.id,
919
937
  until: r.held.until,
@@ -930,6 +948,8 @@ export const createOtalessBookings = (deps) => {
930
948
  adults: 'guests not as asked',
931
949
  address: 'payment page not accepted',
932
950
  terms: 'terms not agreed by the guest',
951
+ confirm: 'not confirmed by the guest',
952
+ 'confirm-unsent': 'its confirmation cannot be sent back yet',
933
953
  };
934
954
  /** Thrown where there is no sign-in at the order's group to cancel it with. */
935
955
  class NotSignedIn extends Error {
@@ -979,6 +999,8 @@ export const createOtalessBookings = (deps) => {
979
999
  adults: `${g} took the order for another number of guests than the guest chose`,
980
1000
  address: `${g} sent a payment page on an address this connector does not send guests to`,
981
1001
  terms: `${g} asked for terms of its own to be agreed to when it was ordered, which cannot be shown here`,
1002
+ confirm: `${g} made the order asking for it to be confirmed, with nothing here the guest could confirm as they were shown it`,
1003
+ 'confirm-unsent': `${g} asked for the order to be confirmed first, and that confirmation cannot be sent back from here yet`,
982
1004
  })[why];
983
1005
  /** An order made that is not the one asked for: cancelled at once, and said as it came out. */
984
1006
  const letGo = async (a, r, why) => {
@@ -988,7 +1010,11 @@ export const createOtalessBookings = (deps) => {
988
1010
  return {
989
1011
  failed: failedStay(a, `${releasedWhy(g, why)}, so the order was cancelled at once and nothing was charged.${why === 'price' ? ' Price the trip again.' : ''}`,
990
1012
  // For the card to say in the guest's language (酒店平台 0.66.0, `NoRoomsCode`).
991
- why === 'price' || why === 'amount' ? 'price-changed' : 'order-cancelled'),
1013
+ why === 'price' || why === 'amount'
1014
+ ? 'price-changed'
1015
+ : why === 'confirm-unsent'
1016
+ ? 'group-confirm'
1017
+ : 'order-cancelled'),
992
1018
  };
993
1019
  // ⚠️ SAID AS IT IS: an order stands at the group that is not the one asked
994
1020
  // for - never "not booked". Listed, with no page to pay it on.
@@ -1007,6 +1033,8 @@ export const createOtalessBookings = (deps) => {
1007
1033
  * only: whose sign-in its time running out is cancelled with.
1008
1034
  */
1009
1035
  const heldBy = new Map();
1036
+ /** What a held order is cancelled for when it is not agreed to or confirmed. */
1037
+ const heldFor = (r) => r.held?.step === 'confirm' ? 'confirm' : 'terms';
1010
1038
  /** A held order whose time ran out - or is past it already (not a number): due. */
1011
1039
  const heldOver = (r) => !(now() < Date.parse(r.held?.until ?? ''));
1012
1040
  /**
@@ -1022,7 +1050,7 @@ export const createOtalessBookings = (deps) => {
1022
1050
  const key = heldBy.get(id);
1023
1051
  const who = { sessionId: key ?? '' };
1024
1052
  const acct = key ? accountFor(who, r.group) : undefined;
1025
- await release(acct && acct.owner === r.owner ? acct : undefined, who, r, 'terms');
1053
+ await release(acct && acct.owner === r.owner ? acct : undefined, who, r, heldFor(r));
1026
1054
  };
1027
1055
  /** A held order's time, kept: `lapse` just after it - for whichever conversation saw it last. */
1028
1056
  const holdFor = (r, key) => {
@@ -1040,7 +1068,7 @@ export const createOtalessBookings = (deps) => {
1040
1068
  continue;
1041
1069
  const acct = accountFor(who, r.group);
1042
1070
  if (acct && acct.owner === r.owner)
1043
- await release(acct, who, r, 'terms');
1071
+ await release(acct, who, r, heldFor(r));
1044
1072
  }
1045
1073
  };
1046
1074
  // ⚠️ HELD ORDERS KEPT ACROSS A RESTART (总线程's review of 0.66.0, 1): their
@@ -1085,9 +1113,11 @@ export const createOtalessBookings = (deps) => {
1085
1113
  const charged = moneyOf(w.totalAmount, w.currency);
1086
1114
  if (charged)
1087
1115
  r.charged = charged;
1088
- if (/TERMS/.test(status)) {
1089
- log(`[otaless] booking at ${a.group} made ${forTheLog(id)} asking for terms - cancelled`);
1090
- return letGo(a, r, 'terms');
1116
+ // A step the group asks for, the order made (questions #66, #68).
1117
+ const step = /TERMS/.test(status) ? 'terms' : stepAsked(status);
1118
+ if (step && !deps.proceedWithoutGroupConfirm) {
1119
+ log(`[otaless] booking at ${a.group} made ${forTheLog(id)} asking for ${step === 'terms' ? 'terms' : 'it to be confirmed'} - cancelled (questions #${step === 'terms' ? 66 : 68}; proceedWithoutGroupConfirm off)`);
1120
+ return letGo(a, r, step === 'terms' ? 'terms' : 'confirm-unsent');
1091
1121
  }
1092
1122
  // ── the amount (总线程 11-10, 12.9 #2): either of this quote's two, to the cent ──
1093
1123
  if (!charged || !(same(charged, pairs.orig) || same(charged, pairs.usd))) {
@@ -1126,6 +1156,43 @@ export const createOtalessBookings = (deps) => {
1126
1156
  log(`[otaless] booking at ${a.group} came with terms too long to show - cancelled`);
1127
1157
  return letGo(a, r, 'terms');
1128
1158
  }
1159
+ // ── a step the group asks for, the order made (proceedWithoutGroupConfirm) ──
1160
+ // Checked as any order above. ⚠️ WHAT IT SENT TO AGREE TO OR CONFIRM IS THE
1161
+ // GUEST'S (总线程's review of 0.67.0, 2): its page held back until they do -
1162
+ // not, or not in time, cancelled (9). Nothing sent: handed on (robin 11-12),
1163
+ // and the booking says the step could not be sent back.
1164
+ if (step) {
1165
+ const asked = groupStepOf(step, w);
1166
+ const q = step === 'terms' ? 66 : 68;
1167
+ if (asked) {
1168
+ const off = stepOff(asked, a, pairs);
1169
+ const other = !!said &&
1170
+ termsKey(said) !== termsKey(a.agreed) &&
1171
+ (step === 'confirm' || termsKey(said) !== termsKey(asked.text));
1172
+ if (off || other) {
1173
+ log(`[otaless] booking ${forTheLog(id)} at ${a.group} answered ${step}_required ${off ? `for ${off} than the guest was shown` : 'and came with other terms too'} - cancelled (questions #${q})`);
1174
+ return letGo(a, r, other ? 'terms' : step === 'confirm' ? 'confirm' : 'terms');
1175
+ }
1176
+ if (step === 'confirm') {
1177
+ if (said)
1178
+ r.terms = said;
1179
+ r.confirmText = asked.text;
1180
+ r.held = { until: iso(now() + TERMS_MS), step: 'confirm' };
1181
+ }
1182
+ else {
1183
+ r.terms = asked.text;
1184
+ r.termsNew = true;
1185
+ r.held = { until: iso(now() + TERMS_MS) };
1186
+ }
1187
+ put(r);
1188
+ log(`[otaless] booking ${forTheLog(id)} at ${a.group} answered ${step}_required with what to ${step === 'terms' ? 'agree to' : 'confirm'} - its payment page held back for the guest (questions #${q})`);
1189
+ holdFor(r, a.acct.key);
1190
+ const t = termsOfHeld(r, a.acct);
1191
+ return t ? { terms: t } : { booked: toBooking(r) };
1192
+ }
1193
+ r.stepUnsent = step;
1194
+ log(`[otaless] booking ${forTheLog(id)} at ${a.group} answered ${step}_required with nothing to ${step === 'terms' ? 'agree to' : 'confirm'} and no token - handed on with its order, the checks passed (proceedWithoutGroupConfirm; questions #${q})`);
1195
+ }
1129
1196
  if (said &&
1130
1197
  termsKey(said) !== termsKey(a.agreed) &&
1131
1198
  !(a.groupStep?.step === 'terms' && termsKey(said) === termsKey(a.groupStep.text))) {
@@ -1133,6 +1200,7 @@ export const createOtalessBookings = (deps) => {
1133
1200
  // back until the guest agrees to these too - not agreed, or not in time,
1134
1201
  // it is cancelled.
1135
1202
  r.terms = said;
1203
+ r.termsNew = true;
1136
1204
  r.held = { until: iso(now() + TERMS_MS) };
1137
1205
  put(r);
1138
1206
  log(`[otaless] booking ${forTheLog(id)} at ${a.group} came with other terms than the guest agreed to - its payment page held back`);
@@ -1456,8 +1524,7 @@ export const createOtalessBookings = (deps) => {
1456
1524
  failed.push(failedStay(label, `${deps.groupOf(group).name}'s terms for this room are too long to show in full here, so nothing was booked.`));
1457
1525
  continue;
1458
1526
  }
1459
- // ⚠️ NOTHING IS ORDERED YET (§15.1): the terms first, for the guest to agree to.
1460
- terms.push(termsBefore({
1527
+ const ask = {
1461
1528
  acct,
1462
1529
  who,
1463
1530
  hotel,
@@ -1469,7 +1536,27 @@ export const createOtalessBookings = (deps) => {
1469
1536
  agreed,
1470
1537
  guest: g0,
1471
1538
  total: line.total,
1472
- }));
1539
+ };
1540
+ // No terms for this room to agree to, and the deployment lets that go on
1541
+ // (robin 11-12 「条款没有也让走下一步」): ordered now - said on the booking.
1542
+ if (!agreed && deps.proceedWithoutGroupConfirm) {
1543
+ inFlight.add(lockKey);
1544
+ try {
1545
+ const out = await place({ ...ask, noTerms: true });
1546
+ if (out.booked)
1547
+ booked.push(out.booked);
1548
+ if (out.failed)
1549
+ failed.push(out.failed);
1550
+ if (out.terms)
1551
+ terms.push(out.terms);
1552
+ }
1553
+ finally {
1554
+ inFlight.delete(lockKey);
1555
+ }
1556
+ continue;
1557
+ }
1558
+ // ⚠️ NOTHING IS ORDERED YET (§15.1): the terms first, for the guest to agree to.
1559
+ terms.push(termsBefore(ask));
1473
1560
  }
1474
1561
  return {
1475
1562
  booked,
@@ -1511,9 +1598,13 @@ export const createOtalessBookings = (deps) => {
1511
1598
  const r = orders.get(p.orderId);
1512
1599
  if (!r || r.owner !== acct.owner || r.released || !r.held)
1513
1600
  throw termsGone();
1601
+ const confirming = r.held.step === 'confirm';
1514
1602
  r.held = undefined;
1603
+ r.termsNew = undefined;
1515
1604
  put(r);
1516
- log(`[otaless] the guest agreed to the terms ${r.group} answered ${forTheLog(r.id)} with - its payment page handed on`);
1605
+ log(confirming
1606
+ ? `[otaless] the guest confirmed what ${r.group} asked to confirm for ${forTheLog(r.id)} - its payment page handed on (its token is not sent back: 8 has no way to for an order made - questions #68)`
1607
+ : `[otaless] the guest agreed to the terms ${r.group} answered ${forTheLog(r.id)} with - its payment page handed on`);
1517
1608
  return { booked: [toBooking(r)], failed: [] };
1518
1609
  }
1519
1610
  const ask = p.ask;
@@ -1575,8 +1666,8 @@ export const createOtalessBookings = (deps) => {
1575
1666
  const r = orders.get(p.orderId);
1576
1667
  if (!r || r.owner !== acct.owner || r.released || !r.held)
1577
1668
  return {};
1578
- // ⚠️ NOT AGREED: the order it held back is cancelled (总线程 11-11, D).
1579
- await release(acct, who, r, 'terms');
1669
+ // ⚠️ NOT AGREED - OR NOT CONFIRMED: the order it held back is cancelled (总线程 11-11, D).
1670
+ await release(acct, who, r, heldFor(r));
1580
1671
  return { booking: toBooking(r) };
1581
1672
  };
1582
1673
  // ── the bookings, refreshed ───────────────────────────────────────────────
@@ -1871,6 +1962,19 @@ export const createOtalessBookings = (deps) => {
1871
1962
  cancellable: true,
1872
1963
  reason: 'unpaid',
1873
1964
  };
1965
+ // ⚠️ TERMS THE GUEST HAS NOT AGREED TO ARE NOT SAID HERE (总线程's review of
1966
+ // 0.67.0, 1): only that they are not the ones shown before - their words are
1967
+ // on the card and the one-time page.
1968
+ if (r.termsNew)
1969
+ return {
1970
+ ...base,
1971
+ fee: amount,
1972
+ refund: money(0, amount.currency),
1973
+ rule: `The cancellation terms ${g} answered this booking with are not the ones the guest saw before, and the guest has not agreed to them - they are on the card or the one-time page, not here. ${g} says what it keeps when it cancels.`,
1974
+ cancellable: true,
1975
+ feeIsCap: true,
1976
+ feeUnknown: true,
1977
+ };
1874
1978
  // ⚠️ THE GROUP'S OWN TERMS, AS THEY CAME; ONLY WITHOUT THEM THE CAP
1875
1979
  // (总线程 11-10). There is no dry run: what is kept is the group's to say
1876
1980
  // when it cancels - the fee here is the most it could be.
@@ -1960,7 +2064,7 @@ export const createOtalessBookings = (deps) => {
1960
2064
  amount,
1961
2065
  fromPayment: !!r.paidAmount,
1962
2066
  groupDecides: true,
1963
- terms: r.terms ?? '',
2067
+ terms: r.termsNew ? '' : (r.terms ?? ''),
1964
2068
  until: iso(now() + REFUND_PREVIEW_MS),
1965
2069
  };
1966
2070
  };
@@ -2097,6 +2201,8 @@ export const createOtalessBookings = (deps) => {
2097
2201
  .length,
2098
2202
  ordersUnconfirmed: [...orders.values()].filter((o) => o.status === 'unconfirmed').length,
2099
2203
  ordersHeld: [...orders.values()].filter((o) => o.held && !o.released).length,
2204
+ // ⚠️ CHECK AFTER A DEPLOY: 1 on the dev backend's alone (总线程 11-12).
2205
+ proceedWithoutGroupConfirm: deps.proceedWithoutGroupConfirm ? 1 : 0,
2100
2206
  groupSessions: sessions.size,
2101
2207
  termsWaiting: pending.size,
2102
2208
  ...counts,