@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.
- package/README.md +11 -0
- package/dist/account/index.d.ts +21 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +63 -4
- package/dist/account/index.js.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/huazhu/client.d.ts +3 -1
- package/dist/huazhu/client.d.ts.map +1 -1
- package/dist/huazhu/client.js +26 -0
- package/dist/huazhu/client.js.map +1 -1
- package/dist/huazhu/english.d.ts.map +1 -1
- package/dist/huazhu/english.js +11 -0
- package/dist/huazhu/english.js.map +1 -1
- package/dist/otaless/backend.d.ts.map +1 -1
- package/dist/otaless/backend.js +17 -6
- package/dist/otaless/backend.js.map +1 -1
- package/dist/otaless/booking.d.ts +11 -4
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +95 -11
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/fake.d.ts +7 -2
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +4 -2
- package/dist/otaless/fake.js.map +1 -1
- package/dist/otaless/places.d.ts.map +1 -1
- package/dist/otaless/places.js +16 -2
- package/dist/otaless/places.js.map +1 -1
- package/dist/regions.d.ts.map +1 -1
- package/dist/regions.js +25 -2
- package/dist/regions.js.map +1 -1
- package/dist/server.d.ts +4 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +280 -13
- package/dist/server.js.map +1 -1
- package/dist/source-allowlist.d.ts +9 -0
- package/dist/source-allowlist.d.ts.map +1 -1
- package/dist/source-allowlist.js +23 -1
- package/dist/source-allowlist.js.map +1 -1
- package/dist/state.d.ts +25 -2
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +88 -15
- package/dist/state.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +61 -2
- package/dist/tools.js.map +1 -1
- package/dist/usage/boot.d.ts +32 -0
- package/dist/usage/boot.d.ts.map +1 -0
- package/dist/usage/boot.js +140 -0
- package/dist/usage/boot.js.map +1 -0
- package/dist/usage/geo.d.ts +48 -0
- package/dist/usage/geo.d.ts.map +1 -0
- package/dist/usage/geo.js +347 -0
- package/dist/usage/geo.js.map +1 -0
- package/dist/usage/maintain.d.ts +26 -0
- package/dist/usage/maintain.d.ts.map +1 -0
- package/dist/usage/maintain.js +177 -0
- package/dist/usage/maintain.js.map +1 -0
- package/dist/usage/platform.d.ts +69 -0
- package/dist/usage/platform.d.ts.map +1 -0
- package/dist/usage/platform.js +124 -0
- package/dist/usage/platform.js.map +1 -0
- package/dist/usage/pseudonym.d.ts +28 -0
- package/dist/usage/pseudonym.d.ts.map +1 -0
- package/dist/usage/pseudonym.js +73 -0
- package/dist/usage/pseudonym.js.map +1 -0
- package/dist/usage/range.d.ts +24 -0
- package/dist/usage/range.d.ts.map +1 -0
- package/dist/usage/range.js +102 -0
- package/dist/usage/range.js.map +1 -0
- package/dist/usage/recorder.d.ts +115 -0
- package/dist/usage/recorder.d.ts.map +1 -0
- package/dist/usage/recorder.js +227 -0
- package/dist/usage/recorder.js.map +1 -0
- package/dist/usage/report.d.ts +207 -0
- package/dist/usage/report.d.ts.map +1 -0
- package/dist/usage/report.js +730 -0
- package/dist/usage/report.js.map +1 -0
- package/dist/usage/shadow-import.d.ts +28 -0
- package/dist/usage/shadow-import.d.ts.map +1 -0
- package/dist/usage/shadow-import.js +107 -0
- package/dist/usage/shadow-import.js.map +1 -0
- package/dist/usage/store.d.ts +215 -0
- package/dist/usage/store.d.ts.map +1 -0
- package/dist/usage/store.js +430 -0
- package/dist/usage/store.js.map +1 -0
- package/dist/usage-cli.d.ts +3 -0
- package/dist/usage-cli.d.ts.map +1 -0
- package/dist/usage-cli.js +152 -0
- package/dist/usage-cli.js.map +1 -0
- package/package.json +3 -2
package/dist/otaless/booking.js
CHANGED
|
@@ -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", "-")
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
1724
|
-
const
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
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,
|