@curless/hotel-storefront 0.69.3 → 0.70.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 (92) hide show
  1. package/README.md +11 -0
  2. package/dist/account/index.d.ts +21 -0
  3. package/dist/account/index.d.ts.map +1 -1
  4. package/dist/account/index.js +63 -4
  5. package/dist/account/index.js.map +1 -1
  6. package/dist/config.d.ts +12 -0
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js.map +1 -1
  9. package/dist/huazhu/client.d.ts +3 -1
  10. package/dist/huazhu/client.d.ts.map +1 -1
  11. package/dist/huazhu/client.js +26 -0
  12. package/dist/huazhu/client.js.map +1 -1
  13. package/dist/huazhu/english.d.ts.map +1 -1
  14. package/dist/huazhu/english.js +11 -0
  15. package/dist/huazhu/english.js.map +1 -1
  16. package/dist/otaless/backend.d.ts.map +1 -1
  17. package/dist/otaless/backend.js +17 -6
  18. package/dist/otaless/backend.js.map +1 -1
  19. package/dist/otaless/booking.d.ts +11 -4
  20. package/dist/otaless/booking.d.ts.map +1 -1
  21. package/dist/otaless/booking.js +95 -11
  22. package/dist/otaless/booking.js.map +1 -1
  23. package/dist/otaless/fake.d.ts +7 -2
  24. package/dist/otaless/fake.d.ts.map +1 -1
  25. package/dist/otaless/fake.js +4 -2
  26. package/dist/otaless/fake.js.map +1 -1
  27. package/dist/otaless/places.d.ts.map +1 -1
  28. package/dist/otaless/places.js +16 -2
  29. package/dist/otaless/places.js.map +1 -1
  30. package/dist/regions.d.ts.map +1 -1
  31. package/dist/regions.js +25 -2
  32. package/dist/regions.js.map +1 -1
  33. package/dist/server.d.ts +4 -1
  34. package/dist/server.d.ts.map +1 -1
  35. package/dist/server.js +280 -13
  36. package/dist/server.js.map +1 -1
  37. package/dist/source-allowlist.d.ts +9 -0
  38. package/dist/source-allowlist.d.ts.map +1 -1
  39. package/dist/source-allowlist.js +23 -1
  40. package/dist/source-allowlist.js.map +1 -1
  41. package/dist/state.d.ts +25 -2
  42. package/dist/state.d.ts.map +1 -1
  43. package/dist/state.js +88 -15
  44. package/dist/state.js.map +1 -1
  45. package/dist/tools.d.ts.map +1 -1
  46. package/dist/tools.js +61 -2
  47. package/dist/tools.js.map +1 -1
  48. package/dist/usage/boot.d.ts +32 -0
  49. package/dist/usage/boot.d.ts.map +1 -0
  50. package/dist/usage/boot.js +140 -0
  51. package/dist/usage/boot.js.map +1 -0
  52. package/dist/usage/geo.d.ts +48 -0
  53. package/dist/usage/geo.d.ts.map +1 -0
  54. package/dist/usage/geo.js +347 -0
  55. package/dist/usage/geo.js.map +1 -0
  56. package/dist/usage/maintain.d.ts +26 -0
  57. package/dist/usage/maintain.d.ts.map +1 -0
  58. package/dist/usage/maintain.js +177 -0
  59. package/dist/usage/maintain.js.map +1 -0
  60. package/dist/usage/platform.d.ts +69 -0
  61. package/dist/usage/platform.d.ts.map +1 -0
  62. package/dist/usage/platform.js +124 -0
  63. package/dist/usage/platform.js.map +1 -0
  64. package/dist/usage/pseudonym.d.ts +28 -0
  65. package/dist/usage/pseudonym.d.ts.map +1 -0
  66. package/dist/usage/pseudonym.js +73 -0
  67. package/dist/usage/pseudonym.js.map +1 -0
  68. package/dist/usage/range.d.ts +24 -0
  69. package/dist/usage/range.d.ts.map +1 -0
  70. package/dist/usage/range.js +102 -0
  71. package/dist/usage/range.js.map +1 -0
  72. package/dist/usage/recorder.d.ts +115 -0
  73. package/dist/usage/recorder.d.ts.map +1 -0
  74. package/dist/usage/recorder.js +227 -0
  75. package/dist/usage/recorder.js.map +1 -0
  76. package/dist/usage/report.d.ts +207 -0
  77. package/dist/usage/report.d.ts.map +1 -0
  78. package/dist/usage/report.js +730 -0
  79. package/dist/usage/report.js.map +1 -0
  80. package/dist/usage/shadow-import.d.ts +28 -0
  81. package/dist/usage/shadow-import.d.ts.map +1 -0
  82. package/dist/usage/shadow-import.js +107 -0
  83. package/dist/usage/shadow-import.js.map +1 -0
  84. package/dist/usage/store.d.ts +215 -0
  85. package/dist/usage/store.d.ts.map +1 -0
  86. package/dist/usage/store.js +430 -0
  87. package/dist/usage/store.js.map +1 -0
  88. package/dist/usage-cli.d.ts +3 -0
  89. package/dist/usage-cli.d.ts.map +1 -0
  90. package/dist/usage-cli.js +152 -0
  91. package/dist/usage-cli.js.map +1 -0
  92. package/package.json +3 -2
@@ -110,19 +110,62 @@ const STAND_IN_CODES = new Set([
110
110
  'NONE',
111
111
  'TBD',
112
112
  'TBA',
113
+ 'TBC',
113
114
  'UNKNOWN',
114
115
  'UNDEFINED',
116
+ 'PROCESSING',
117
+ 'WAITING',
118
+ 'TEMP',
119
+ 'TMP',
120
+ 'DRAFT',
121
+ 'PLACEHOLDER',
122
+ // ⚠️ AND EVERY STATE AN ORDER OR ITS PAYMENT IS IN (总线程's re-review of 459565b2, P3): an
123
+ // answer with its status where the number goes - 12's and 15's names, the dictionary's,
124
+ // 8's own steps - is no number. 12's own (PENDING_PAYMENT, CONFIRMED, PAID, REFUNDED…)
125
+ // and 15's (EXPIRED, TIMEOUT…) come from the sets above.
126
+ 'SUCCESS',
127
+ 'REJECTED',
128
+ 'SOLD_OUT',
129
+ 'REFUND_REQUESTED',
130
+ 'CANCEL_FAILED',
131
+ 'TERMS_REQUIRED',
132
+ 'CONFIRM_REQUIRED',
133
+ ...DEAD_ROW_STATUSES,
134
+ ...LIVE_ROW_STATUSES,
135
+ ...CLOSED_PAYMENT_STATUSES,
115
136
  ]);
137
+ /** The fewest characters a group's number is taken at - shorter is a stand-in. */
138
+ const ORDER_CODE_MIN = 4;
116
139
  /**
117
140
  * A group's own order number that names one order - anything but a stand-in:
118
- * empty, noughts and marks alone ("0", "000-0", "-"), or one of `STAND_IN_CODES`
119
- * ("PENDING", "n/a", "null"). ⚠️ A NUMBER OF LETTERS ALONE IS A NUMBER (总线程's
120
- * re-review of ea5c5547, P3 2): a group whose numbers have no figure, its payment
121
- * page naming the order by it, had that order cancelled as not this one's.
141
+ * - empty, or noughts and marks alone ("0", "000-0", "-");
142
+ * - one of `STAND_IN_CODES`, in any case and with spaces or hyphens for its
143
+ * underscores ("PENDING", "n/a", "Pending Payment") - an order's state included;
144
+ * - by its shape: a number below nought ("-1"); and, for a code with no figure in it,
145
+ * one character over and over ("XXXX") or fewer than `ORDER_CODE_MIN` characters
146
+ * ("ABC"). A code with a figure in it - "123", "1111", "A1" - is a number.
147
+ * ⚠️ A NUMBER OF LETTERS ALONE IS A NUMBER (总线程's re-review of ea5c5547, P3 2): a group
148
+ * whose numbers have no figure, its payment page naming the order by it, had that order
149
+ * cancelled as not this one's. ⚠️ THE SHAPES ARE A FALLBACK (总线程's re-review of
150
+ * 459565b2, P3): what the backend puts there before an order has its number is for
151
+ * questions #73 to say.
122
152
  */
123
153
  export const realOrderCode = (code) => {
124
154
  const c = (code ?? '').trim();
125
- return !!c && !/^[\s0\p{P}\p{S}]*$/u.test(c) && !STAND_IN_CODES.has(c.toUpperCase());
155
+ if (!c || /^[\s0\p{P}\p{S}]*$/u.test(c))
156
+ return false;
157
+ if (STAND_IN_CODES.has(c.toUpperCase().replace(/[\s-]+/g, '_')))
158
+ return false;
159
+ if (/^-\s*\d+(\.\d+)?$/.test(c))
160
+ return false;
161
+ // ⚠️ FIGURES ALONE, NOT ALL NOUGHTS, ARE A NUMBER - SHORT OR REPEATED (总线程's re-review of
162
+ // 0.69.4, P3): "123" or "1111" naming the order on its payment page had it cancelled as
163
+ // not this one's. The shape rules are for a code with no figure in it.
164
+ if (/\d/.test(c))
165
+ return true;
166
+ if (/^(.)\1*$/su.test(c))
167
+ return false;
168
+ return [...c].length >= ORDER_CODE_MIN;
126
169
  };
127
170
  /** The longest terms shown word for word - longer is refused rather than cut. */
128
171
  export const TERMS_MAX = 50_000;
@@ -1685,6 +1728,40 @@ export const createOtalessBookings = (deps) => {
1685
1728
  };
1686
1729
  return undefined;
1687
1730
  };
1731
+ /**
1732
+ * The trip priced once per currency ITS QUOTES ARE IN (总线程 11-12, after 酒店平台 0.69.3's
1733
+ * `pricedByQuoteCurrency`): one quote of the whole trip, as before - and when the backend
1734
+ * refuses that as `mixed-currency` (a hotel quoted in CNY beside one in USD: Atour's Bund,
1735
+ * listed in USD, quotes CNY - questions #45), each room line quoted on its own to read its
1736
+ * currency, and the lines quoted again by it. Never added across currencies, never converted.
1737
+ * A line with no price on its own is its own answer (dropped). Add-ons are not quoted
1738
+ * again: none is sold here, and `requestBooking` has said so for each already.
1739
+ */
1740
+ const quotedByCurrency = async (trip, who) => {
1741
+ try {
1742
+ return [await deps.quote(trip, who)];
1743
+ }
1744
+ catch (err) {
1745
+ if (err.code !== 'mixed-currency')
1746
+ throw err;
1747
+ }
1748
+ const rooms = trip.lines.filter((l) => l.kind === 'room');
1749
+ const alone = await Promise.all(rooms.map((l) => deps.quote({ lines: [l] }, who)));
1750
+ const byCurrency = new Map();
1751
+ const unpriced = [];
1752
+ rooms.forEach((l, i) => {
1753
+ const p = alone[i];
1754
+ if (!p)
1755
+ return;
1756
+ if (!p.lines.length) {
1757
+ unpriced.push(p);
1758
+ return;
1759
+ }
1760
+ byCurrency.set(p.total.currency, [...(byCurrency.get(p.total.currency) ?? []), l]);
1761
+ });
1762
+ const priced = await Promise.all([...byCurrency.values()].map((g) => deps.quote({ ...trip, lines: g }, who)));
1763
+ return [...priced, ...unpriced];
1764
+ };
1688
1765
  const requestBooking = async (trip, guest, who) => {
1689
1766
  // ⚠️ SIGNED IN AT EVERY GROUP OF THE TRIP, OR NOTHING IS SENT (robin 11-10:
1690
1767
  // one sign-in per group, the backend's own) - the whole trip is refused
@@ -1719,12 +1796,19 @@ export const createOtalessBookings = (deps) => {
1719
1796
  });
1720
1797
  }
1721
1798
  }
1722
- // ⚠️ THE PRICE THE GUEST SAW, OR NOTHING (ShownQuote, 2026-10-05 audit P1-3).
1723
- const q = await deps.quote(trip, who);
1724
- const moved = movedSince(trip.shown, q, !q.dropped?.length);
1725
- if (moved)
1726
- throw refusal('price-changed', `Nothing was booked: ${moved}`);
1727
- for (const d of q.dropped ?? []) {
1799
+ // ⚠️ THE PRICE THE GUEST SAW, OR NOTHING (ShownQuote, 2026-10-05 audit P1-3) - each
1800
+ // currency's stays against that currency's total, as the card showed them.
1801
+ const parts = await quotedByCurrency(trip, who);
1802
+ for (const p of parts) {
1803
+ const moved = movedSince(trip.shown, p, !p.dropped?.length);
1804
+ if (moved)
1805
+ throw refusal('price-changed', `Nothing was booked: ${moved}`);
1806
+ }
1807
+ const q = {
1808
+ lines: parts.flatMap((p) => p.lines),
1809
+ dropped: parts.flatMap((p) => p.dropped ?? []),
1810
+ };
1811
+ for (const d of q.dropped) {
1728
1812
  failed.push({
1729
1813
  hotelId: d.line?.hotelId ?? '',
1730
1814
  hotelName: d.line?.hotelName ?? d.title,