@curless/hotel-storefront 0.43.0 → 0.44.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 (48) hide show
  1. package/dist/card.generated.d.ts +3 -1
  2. package/dist/card.generated.d.ts.map +1 -1
  3. package/dist/card.generated.js +4 -2
  4. package/dist/card.generated.js.map +1 -1
  5. package/dist/config.d.ts +18 -0
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js.map +1 -1
  8. package/dist/huazhu/backend.d.ts +10 -0
  9. package/dist/huazhu/backend.d.ts.map +1 -1
  10. package/dist/huazhu/backend.js +538 -68
  11. package/dist/huazhu/backend.js.map +1 -1
  12. package/dist/huazhu/bookings.d.ts +15 -0
  13. package/dist/huazhu/bookings.d.ts.map +1 -1
  14. package/dist/huazhu/bookings.js.map +1 -1
  15. package/dist/huazhu/client.d.ts +84 -0
  16. package/dist/huazhu/client.d.ts.map +1 -1
  17. package/dist/huazhu/client.js +147 -1
  18. package/dist/huazhu/client.js.map +1 -1
  19. package/dist/huazhu/make.d.ts.map +1 -1
  20. package/dist/huazhu/make.js +35 -1
  21. package/dist/huazhu/make.js.map +1 -1
  22. package/dist/index.js +0 -0
  23. package/dist/limits.d.ts +34 -1
  24. package/dist/limits.d.ts.map +1 -1
  25. package/dist/limits.js +2 -0
  26. package/dist/limits.js.map +1 -1
  27. package/dist/payments/checkout.d.ts +11 -0
  28. package/dist/payments/checkout.d.ts.map +1 -1
  29. package/dist/payments/checkout.js.map +1 -1
  30. package/dist/payments/fake-stripe.d.ts +4 -0
  31. package/dist/payments/fake-stripe.d.ts.map +1 -1
  32. package/dist/payments/fake-stripe.js +21 -1
  33. package/dist/payments/fake-stripe.js.map +1 -1
  34. package/dist/payments/fake-unionpay.d.ts +2 -0
  35. package/dist/payments/fake-unionpay.d.ts.map +1 -1
  36. package/dist/payments/fake-unionpay.js +7 -1
  37. package/dist/payments/fake-unionpay.js.map +1 -1
  38. package/dist/payments/stripe-checkout.d.ts +1 -0
  39. package/dist/payments/stripe-checkout.d.ts.map +1 -1
  40. package/dist/payments/stripe-checkout.js +4 -2
  41. package/dist/payments/stripe-checkout.js.map +1 -1
  42. package/dist/server.d.ts +2 -2
  43. package/dist/server.js +2 -2
  44. package/dist/tools.d.ts +30 -1
  45. package/dist/tools.d.ts.map +1 -1
  46. package/dist/tools.js +49 -2
  47. package/dist/tools.js.map +1 -1
  48. package/package.json +13 -14
package/dist/tools.js CHANGED
@@ -908,6 +908,20 @@ const CANCEL_SCHEMA = {
908
908
  rule: STR,
909
909
  freeUntil: STR,
910
910
  cancellable: BOOL,
911
+ /**
912
+ * What was paid here in advance and what cancelling now gives back of it -
913
+ * only on a booking paid by card or UnionPay that can be cancelled (`PaidFacts`).
914
+ */
915
+ payment: {
916
+ type: 'object',
917
+ properties: {
918
+ method: { enum: ['card', 'unionpay'] },
919
+ amount: STR,
920
+ refund: { enum: ['all', 'part', 'none'] },
921
+ refundAmount: STR,
922
+ },
923
+ required: ['method', 'amount', 'refund'],
924
+ },
911
925
  /** The terms as facts, for the card to say in the guest's language (`CancellationPreview`). */
912
926
  feeIsCap: BOOL,
913
927
  reason: STR,
@@ -1418,6 +1432,19 @@ const bookingForCard = (b) => ({
1418
1432
  quote: quoteForCard(b.quote),
1419
1433
  ...(b.payment ? { payment: { ...b.payment, amount: formatMoney(b.payment.amount) } } : {}),
1420
1434
  });
1435
+ const paidFactsOf = (booked, preview) => {
1436
+ const p = booked?.payment;
1437
+ if (!p || p.status !== 'paid' || !preview.cancellable)
1438
+ return undefined;
1439
+ const back = preview.refund.minor;
1440
+ const refund = back <= 0 ? 'none' : back >= p.amount.minor ? 'all' : 'part';
1441
+ return {
1442
+ method: p.method,
1443
+ amount: formatMoney(p.amount),
1444
+ refund,
1445
+ ...(refund === 'part' ? { refundAmount: formatMoney(preview.refund) } : {}),
1446
+ };
1447
+ };
1421
1448
  /**
1422
1449
  * A booking paid in advance, as the guest is told it - where its money stands.
1423
1450
  * Undefined for any other booking.
@@ -1483,7 +1510,12 @@ const paidLine = (deps, b, fee) => {
1483
1510
  // and not read yet (audit, P0-D) - what is said is what is to be done.
1484
1511
  return unionpay
1485
1512
  ? `**Not booked yet.** ${amount} is to be confirmed on UnionPay's page by ${p.payByLocal ?? p.payBy} hotel time${p.url ? `: ${p.url}` : ''}. Once UnionPay issues its one-time card, the stay is booked with ${h.name}, who charges that card; not confirmed by then, nothing is booked or charged.`
1486
- : `**Not booked yet.** ${amount} is to be paid on the card page by ${p.payByLocal ?? p.payBy} hotel time: ${p.url}. Once it is paid the stay is booked with ${h.name}, and ${deps.tools.listBookings} shows it; unpaid by then, the page closes and nothing is booked or charged.`;
1513
+ : p.url
1514
+ ? `**Not booked yet.** ${amount} is to be paid on the card page by ${p.payByLocal ?? p.payBy} hotel time: ${p.url}. Once it is paid the stay is booked with ${h.name}, and ${deps.tools.listBookings} shows it; unpaid by then, the page closes and nothing is booked or charged.`
1515
+ : // ⚠️ NO LINK IS NOT "undefined" (2026-10-21 re-audit, T2-6): a card
1516
+ // page that was closed and could not be opened again leaves a stay
1517
+ // waiting with nowhere to pay it. Say so, and that it lapses.
1518
+ `**Not booked yet.** ${amount} is to be paid on the card page by ${p.payByLocal ?? p.payBy} hotel time, but the page's link is not available just now - ask again later (${deps.tools.listBookings} shows where it stands). Nothing is booked or charged until it is paid; if no page comes by then, the stay lapses and can be asked for again.`;
1487
1519
  case 'issued':
1488
1520
  return `Confirmed on UnionPay: ${h.name} is being asked to book it now, and ${deps.tools.listBookings} shows when it has. If ${h.name} does not take it, the one-time card is not charged.`;
1489
1521
  case 'paid':
@@ -3940,8 +3972,18 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
3940
3972
  // each call opens UnionPay's card page or its confirmation through the
3941
3973
  // gateway - fifty of them used up its key's limit for every guest. A
3942
3974
  // guest's own card takes a press, a "continue" and a reopen at most.
3975
+ //
3976
+ // ⚠️ THE STAY'S COUNT IS KEPT PER CODE AND EMAIL, NEVER PER CODE (2026-10-21
3977
+ // re-audit, T2-11). The count is made BEFORE the backend checks the email,
3978
+ // so with the code alone as its key anyone who knew only a code - one is
3979
+ // printed on a confirmation, or read over a shoulder - could ask five times
3980
+ // with any email and use up the stay's quarter of an hour, and the guest's
3981
+ // own press was refused as "too many". Keyed with the email asked, a wrong
3982
+ // email counts against itself: the guest's pair is the guest's alone. The
3983
+ // conversation and the address are counted as before. (The backend counts
3984
+ // a stay's asks too, but only once the pair has matched.)
3943
3985
  const tries = [
3944
- `unionpay|booking|${code.trim().toLowerCase()}`,
3986
+ `unionpay|booking|${code.trim().toLowerCase()}|${email.trim().toLowerCase()}`,
3945
3987
  `unionpay|session|${who.sessionId}`,
3946
3988
  ...(ctx.ip ? [`ip|unionpay|${ctx.ip}`] : []),
3947
3989
  ];
@@ -4201,6 +4243,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
4201
4243
  ...(booked?.quote.lines.some((l) => l.kind === 'extra') ? { addOnsFree: true } : {}),
4202
4244
  }
4203
4245
  : {};
4246
+ // Money already paid here, and what comes back: see `paidFactsOf`.
4247
+ const paid = paidFactsOf(booked, preview);
4204
4248
  const asPreview = {
4205
4249
  structured: {
4206
4250
  view: 'cancellation-preview',
@@ -4236,6 +4280,9 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
4236
4280
  rule: preview.rule,
4237
4281
  freeUntil: preview.freeUntil,
4238
4282
  cancellable: preview.cancellable,
4283
+ // What was paid and what comes back - the half of `rule` the card does
4284
+ // not show once it says the terms from the facts below.
4285
+ ...(paid ? { payment: paid } : {}),
4239
4286
  // The terms as facts, so the card can say them in the guest's language
4240
4287
  // instead of showing `rule` as the backend wrote it. Money becomes a
4241
4288
  // string here like `fee`; `free` is a step whose fee is nothing, so the