@curless/hotel-storefront 0.72.1 → 0.72.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.
- package/dist/account/ota-member.d.ts +6 -4
- package/dist/account/ota-member.d.ts.map +1 -1
- package/dist/account/ota-member.js +37 -6
- package/dist/account/ota-member.js.map +1 -1
- package/dist/account/pages.d.ts +0 -1
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +2 -5
- package/dist/account/pages.js.map +1 -1
- package/dist/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/otaless/backend.d.ts.map +1 -1
- package/dist/otaless/backend.js +49 -11
- package/dist/otaless/backend.js.map +1 -1
- package/dist/otaless/booking.d.ts +9 -0
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +86 -10
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/client.d.ts +33 -5
- package/dist/otaless/client.d.ts.map +1 -1
- package/dist/otaless/client.js +45 -7
- package/dist/otaless/client.js.map +1 -1
- package/dist/otaless/fake.d.ts +15 -0
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +33 -3
- package/dist/otaless/fake.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +4 -1
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/otaless/booking.js
CHANGED
|
@@ -4,7 +4,7 @@ import { guestTooLong } from '../backend.js';
|
|
|
4
4
|
import { nights as nightsOf } from '../dates.js';
|
|
5
5
|
import { movedSince } from '../huazhu/backend.js';
|
|
6
6
|
import { decimalsOf, minorFactor, money, toMinor } from '../money.js';
|
|
7
|
-
import { CHANNEL_SESSION_EXPIRED, NOT_SIGNED_IN, OtalessBusy, OtalessError, REPEAT_SUBMIT, SESSION_ID, forTheLog, isBookingTerms, } from './client.js';
|
|
7
|
+
import { CHANNEL_SESSION_EXPIRED, NOT_SIGNED_IN, OtalessBusy, OtalessError, REPEAT_SUBMIT, SESSION_ID, forTheLog, isBookingTerms, priceTaken, } from './client.js';
|
|
8
8
|
// Booking on the Otaless hotel backend: items 8-16 of its document of
|
|
9
9
|
// 2026-11-10. Since 2026-11-11 the order is 8 `booking/create` - the backend's
|
|
10
10
|
// own answer to questions #56: 「booking/create 就行,checkout 所有的 api 不需要」
|
|
@@ -514,6 +514,42 @@ export const pageShape = (raw, order) => {
|
|
|
514
514
|
* group's answer formatted a little differently is not new terms to agree to.
|
|
515
515
|
*/
|
|
516
516
|
export const termsKey = (s) => s.normalize('NFKC').replace(/[\s\p{P}]/gu, '');
|
|
517
|
+
/**
|
|
518
|
+
* 8's `termsPoints`, a point a line (0.72.2): a list - or a list written out as JSON text,
|
|
519
|
+
* as apidev sent Ascott's on 11-16 (「["Children: …","Cancellation policy: …",…]」) - is its
|
|
520
|
+
* points, each word for word; any other text is one point, as it came. Nothing translated,
|
|
521
|
+
* nothing dropped: a point that is not text is written as JSON.
|
|
522
|
+
*/
|
|
523
|
+
export const pointsOf = (v) => {
|
|
524
|
+
let list = v;
|
|
525
|
+
if (typeof v === 'string') {
|
|
526
|
+
const t = v.trim();
|
|
527
|
+
if (!t)
|
|
528
|
+
return [];
|
|
529
|
+
if (!(t.startsWith('[') && t.endsWith(']')))
|
|
530
|
+
return [t];
|
|
531
|
+
try {
|
|
532
|
+
list = JSON.parse(t);
|
|
533
|
+
}
|
|
534
|
+
catch {
|
|
535
|
+
return [t];
|
|
536
|
+
}
|
|
537
|
+
if (!Array.isArray(list))
|
|
538
|
+
return [t];
|
|
539
|
+
}
|
|
540
|
+
if (!Array.isArray(list))
|
|
541
|
+
return [];
|
|
542
|
+
return list.flatMap((x) => {
|
|
543
|
+
const s = typeof x === 'string'
|
|
544
|
+
? x.trim()
|
|
545
|
+
: x === null || x === undefined
|
|
546
|
+
? ''
|
|
547
|
+
: typeof x === 'object'
|
|
548
|
+
? JSON.stringify(x)
|
|
549
|
+
: String(x);
|
|
550
|
+
return s ? [s] : [];
|
|
551
|
+
});
|
|
552
|
+
};
|
|
517
553
|
/** Which step a refusal of 8 - or its status - asks for, or none. */
|
|
518
554
|
export const stepAsked = (said) => {
|
|
519
555
|
const s = String(said ?? '');
|
|
@@ -894,6 +930,13 @@ export const createOtalessBookings = (deps) => {
|
|
|
894
930
|
// it separately; and an order made with no terms to agree to.
|
|
895
931
|
r.stepUnsent ? { confirmUnseen: true } : {}, r.noTerms ? { noTermsGiven: true } : {}, r.autoAccepted ? { groupTermsAutoAccepted: true } : {});
|
|
896
932
|
};
|
|
933
|
+
/**
|
|
934
|
+
* 8 asked for the group's own terms, nothing agreed by the guest yet (0.72.1): sent with
|
|
935
|
+
* `termsRequired: true`, it answers them and orders nothing - as the document has it.
|
|
936
|
+
* Not a room with no terms ordered at once (`noTerms`), nor one whose own terms the guest
|
|
937
|
+
* agreed to (`/site` not saying, `agreed`): those may order.
|
|
938
|
+
*/
|
|
939
|
+
const asksTermsOnly = (a) => a.groupTerms === 'ask' && !a.agreed && !a.noTerms;
|
|
897
940
|
const failedStay = (a, why, code) => ({
|
|
898
941
|
hotelId: a.hotel.id,
|
|
899
942
|
hotelName: a.hotel.name,
|
|
@@ -1110,13 +1153,17 @@ export const createOtalessBookings = (deps) => {
|
|
|
1110
1153
|
(roomSaid && tail(roomSaid) !== tail(a.roomId)) ||
|
|
1111
1154
|
(groupSaid && groupSaid !== a.group))
|
|
1112
1155
|
return notBooked('for another hotel or room than the one asked', `${g.name} sent terms for another hotel or room than the one asked for, so nothing was booked or charged.`);
|
|
1113
|
-
// Word for word, each as the group wrote it - the same twice is shown once.
|
|
1156
|
+
// Word for word, each as the group wrote it - the same twice is shown once. Its points,
|
|
1157
|
+
// a list, one a line (0.72.2 - robin's Ascott run of 11-16 had them drawn as one string of
|
|
1158
|
+
// JSON, brackets and quotes and all): `pointsOf`.
|
|
1159
|
+
const points = pointsOf(w.termsPoints);
|
|
1114
1160
|
const parts = [];
|
|
1115
|
-
for (const
|
|
1116
|
-
|
|
1161
|
+
for (const t of [
|
|
1162
|
+
points.length > 1 ? points.map((p) => `• ${p}`).join('\n') : (points[0] ?? ''),
|
|
1163
|
+
typeof w.cancellation === 'string' ? w.cancellation.trim() : '',
|
|
1164
|
+
])
|
|
1117
1165
|
if (t && !parts.some((p) => termsKey(p) === termsKey(t)))
|
|
1118
1166
|
parts.push(t);
|
|
1119
|
-
}
|
|
1120
1167
|
const shown = parts.join('\n\n');
|
|
1121
1168
|
if (!shown)
|
|
1122
1169
|
return notBooked('with nothing to show', `${g.name} asked for its own terms to be agreed to and sent none to show here, so nothing was booked or charged.`, 'group-terms');
|
|
@@ -1126,7 +1173,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
1126
1173
|
w.acceptArgs !== undefined && w.acceptArgs !== null ? 'acceptArgs' : '',
|
|
1127
1174
|
text(w.confirmToken ?? undefined) ? 'confirmToken' : '',
|
|
1128
1175
|
].filter(Boolean);
|
|
1129
|
-
log(`[otaless] booking at ${a.group} answered its terms (${[
|
|
1176
|
+
log(`[otaless] booking at ${a.group} answered its terms (${[points.length ? `termsPoints${points.length > 1 || Array.isArray(w.termsPoints) ? ` - ${points.length} points` : ''}` : '', text(w.cancellation ?? undefined) ? 'cancellation' : ''].filter(Boolean).join(', ')}) - shown to the guest, nothing ordered${unsent.length ? `; ${unsent.join(', ')} not sent back (questions #79)` : ''}`);
|
|
1130
1177
|
return {
|
|
1131
1178
|
terms: remember({
|
|
1132
1179
|
ref: randomBytes(18).toString('base64url'),
|
|
@@ -1146,7 +1193,14 @@ export const createOtalessBookings = (deps) => {
|
|
|
1146
1193
|
until: iso(now() + TERMS_MS),
|
|
1147
1194
|
owner: a.acct.owner,
|
|
1148
1195
|
key: a.acct.key,
|
|
1149
|
-
|
|
1196
|
+
// Each point too, shown whole on a line of its own: an order whose terms are one of
|
|
1197
|
+
// them is one the guest agreed to (`agreedTo`).
|
|
1198
|
+
ask: {
|
|
1199
|
+
roomId: a.roomId,
|
|
1200
|
+
guest: a.guest,
|
|
1201
|
+
groupTerms: 'answered',
|
|
1202
|
+
parts: points.length > 1 ? [...parts, ...points] : parts,
|
|
1203
|
+
},
|
|
1150
1204
|
}),
|
|
1151
1205
|
};
|
|
1152
1206
|
};
|
|
@@ -1456,7 +1510,10 @@ export const createOtalessBookings = (deps) => {
|
|
|
1456
1510
|
const settle = async (a, w, pairs) => {
|
|
1457
1511
|
// ⚠️ THE GROUP'S TERMS, NOT AN ORDER (0.72.1): 8 asked with `termsRequired: true`
|
|
1458
1512
|
// answers them with no order id - never an order "being looked into" (核对中) below.
|
|
1459
|
-
|
|
1513
|
+
// ⚠️ ONLY AN 8 SENT WITH `termsRequired` (总线程's review of 0.72.1, P3-1): at a group
|
|
1514
|
+
// that asks for no terms (Atour, JI - `/site` false) every answer is an order's, and
|
|
1515
|
+
// one with no id is one being looked into - never "not booked", booked again.
|
|
1516
|
+
if (a.groupTerms && isBookingTerms(w))
|
|
1460
1517
|
return termsFrom8(a, w);
|
|
1461
1518
|
return settleOrder(a, w, pairs);
|
|
1462
1519
|
};
|
|
@@ -1614,7 +1671,7 @@ export const createOtalessBookings = (deps) => {
|
|
|
1614
1671
|
// and then did not. The order's own terms - or the room's - are the guest's to agree to
|
|
1615
1672
|
// before its page is handed on; with none to show, it is cancelled.
|
|
1616
1673
|
// (A room with no terms ordered at once - `noTerms`, proceedWithoutGroupConfirm - is not.)
|
|
1617
|
-
const unagreed = a
|
|
1674
|
+
const unagreed = asksTermsOnly(a);
|
|
1618
1675
|
const toAgree = unagreed
|
|
1619
1676
|
? (said ?? text(a.roomTerms))
|
|
1620
1677
|
: said && !agreedTo(said, a)
|
|
@@ -1733,7 +1790,12 @@ export const createOtalessBookings = (deps) => {
|
|
|
1733
1790
|
throw notPriced(again);
|
|
1734
1791
|
}
|
|
1735
1792
|
}
|
|
1736
|
-
|
|
1793
|
+
// Its own currency - or, with none, its settlement's (`priceTaken`, questions #45):
|
|
1794
|
+
// the same as the price the guest was shown, so held to it the same.
|
|
1795
|
+
const p = priceTaken(priced.data);
|
|
1796
|
+
const orig = moneyOf(p.amount, p.currency);
|
|
1797
|
+
if (p.settled && orig)
|
|
1798
|
+
deps.pricedInSettlement?.(a.hotel.id);
|
|
1737
1799
|
// ⚠️ THE PRICE THE GUEST SAW, TO THE CENT, OR 8 IS NOT CALLED.
|
|
1738
1800
|
if (!orig || !same(orig, a.total))
|
|
1739
1801
|
throw new Moved('moved');
|
|
@@ -1835,6 +1897,20 @@ export const createOtalessBookings = (deps) => {
|
|
|
1835
1897
|
};
|
|
1836
1898
|
if (err instanceof OtalessBusy)
|
|
1837
1899
|
return { failed: limited(a, g.name) };
|
|
1900
|
+
// ⚠️ THE GROUP'S TERMS ASKED FOR, NOTHING AGREED - A 10014 IS NO ORDER (总线程's review
|
|
1901
|
+
// of 0.72.1, P2-1): 8 sent with `termsRequired: true` answers the terms and orders
|
|
1902
|
+
// nothing, so its repeat refused (10014) - Book pressed twice at Ascott, or asked again
|
|
1903
|
+
// by the model within the window - is a repeat of terms asked a moment ago, never an
|
|
1904
|
+
// order "being looked into": kept as one, it held the stay back for
|
|
1905
|
+
// UNCONFIRMED_GIVE_UP_MS once the guest agreed on the first card. Said as the group's
|
|
1906
|
+
// "wait a moment", nothing kept. (One that did not answer is kept as below all the
|
|
1907
|
+
// same: a `/site` out of date may have it order at once.)
|
|
1908
|
+
if (err === fromBook && isCode(err, REPEAT_SUBMIT) && asksTermsOnly(a)) {
|
|
1909
|
+
log(`[otaless] booking at ${a.group}: 8 asking for its terms answered 10014 - a repeat of terms asked a moment ago, which order nothing; not booked, nothing kept`);
|
|
1910
|
+
return {
|
|
1911
|
+
failed: failedStay(a, `${g.name} asked us to wait a moment before asking for its terms again, so nothing was booked or charged - the guest can press Book again in a few seconds.`, 'group-wait'),
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1838
1914
|
// ⚠️ NOT SENT AGAIN (§12.1): 8 itself not answering - or refusing it as a
|
|
1839
1915
|
// repeat of one that went in a moment ago (10014) - may have made it.
|
|
1840
1916
|
// Kept to look for in the group's order list (12), said as not known.
|