@curless/hotel-storefront 0.74.4 → 0.74.6
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/index.d.ts +6 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +86 -13
- package/dist/account/index.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/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/otaless/backend.d.ts +2 -0
- package/dist/otaless/backend.d.ts.map +1 -1
- package/dist/otaless/backend.js +71 -7
- package/dist/otaless/backend.js.map +1 -1
- package/dist/otaless/booking.d.ts +6 -0
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +81 -13
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/client.d.ts +55 -3
- package/dist/otaless/client.d.ts.map +1 -1
- package/dist/otaless/client.js +56 -12
- package/dist/otaless/client.js.map +1 -1
- package/dist/otaless/fake.d.ts +6 -0
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +30 -0
- package/dist/otaless/fake.js.map +1 -1
- package/dist/otaless/make.d.ts.map +1 -1
- package/dist/otaless/make.js +17 -0
- package/dist/otaless/make.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -2
- package/dist/server.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +101 -27
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +29 -0
- package/dist/types.d.ts.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, priceTaken, } from './client.js';
|
|
7
|
+
import { CHANNEL_SESSION_EXPIRED, NOT_SIGNED_IN, OtalessBusy, OtalessError, REPEAT_SUBMIT, SESSION_ID, forTheLog, isBookingTerms, localeAsked, 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 不需要」
|
|
@@ -751,6 +751,8 @@ export const createOtalessBookings = (deps) => {
|
|
|
751
751
|
termsSent: 0,
|
|
752
752
|
termsAgreed: 0,
|
|
753
753
|
sessionRetried: 0,
|
|
754
|
+
/** 16 refused as a repeat (10014) and asked once more after the pause (0.74.5). */
|
|
755
|
+
initRepeated: 0,
|
|
754
756
|
/** Cancelled, and the refund the cancel asked (9.1) not taken - a person takes it up (0.74.2). */
|
|
755
757
|
refundNotSent: 0,
|
|
756
758
|
/** …or not answered: whether it was sent is not known (0.74.3). */
|
|
@@ -850,14 +852,18 @@ export const createOtalessBookings = (deps) => {
|
|
|
850
852
|
sessions.delete(first);
|
|
851
853
|
}
|
|
852
854
|
};
|
|
853
|
-
/**
|
|
855
|
+
/**
|
|
856
|
+
* A fresh handshake (16) - with the sign-in's token, never anonymous (总线程 11-10).
|
|
857
|
+
*
|
|
858
|
+
* ⚠️ 16 REFUSED AS A REPEAT (10014) IS ASKED ONCE MORE, `QUOTE_REPEAT_PAUSE_MS` ON (0.74.5,
|
|
859
|
+
* robin's demo 11-17 07:36-07:47 UTC: Shangri-La's and JI's 8 answered 4012, the handshake
|
|
860
|
+
* right after it 10014 - the one before 8 had gone in a moment earlier - and the booking was
|
|
861
|
+
* only "not taken"). As a 7 is: past the backend's `@RepeatSubmit` window. A handshake orders
|
|
862
|
+
* nothing. Once only: a second 10014 is thrown as it came.
|
|
863
|
+
*/
|
|
854
864
|
const handshake = async (acct, who) => {
|
|
855
865
|
const group = acct.group;
|
|
856
|
-
|
|
857
|
-
try {
|
|
858
|
-
sent = await client.initialize(group, { token: acct.token }, deps.callerOf(who));
|
|
859
|
-
}
|
|
860
|
-
catch (err) {
|
|
866
|
+
const refused = (err) => {
|
|
861
867
|
if (err instanceof OtalessError &&
|
|
862
868
|
!(err instanceof OtalessBusy) &&
|
|
863
869
|
err.backendCode !== undefined) {
|
|
@@ -868,16 +874,35 @@ export const createOtalessBookings = (deps) => {
|
|
|
868
874
|
// 0.74.1 (总线程's review of 0.74.0, P3): the account's sign-in over is said as that -
|
|
869
875
|
// and the group not linked as that - never as the group not taking the booking.
|
|
870
876
|
if (isCode(err, NOT_SIGNED_IN))
|
|
871
|
-
|
|
877
|
+
return signedOut(acct);
|
|
872
878
|
if (unlinkedSaid(err))
|
|
873
|
-
|
|
874
|
-
|
|
879
|
+
return linkFirst(acct, 'initialize said so in its own words');
|
|
880
|
+
return err;
|
|
881
|
+
};
|
|
882
|
+
let sent;
|
|
883
|
+
try {
|
|
884
|
+
sent = await client.initialize(group, { token: acct.token }, deps.callerOf(who));
|
|
885
|
+
}
|
|
886
|
+
catch (err) {
|
|
887
|
+
if (!isCode(err, REPEAT_SUBMIT))
|
|
888
|
+
throw refused(err);
|
|
889
|
+
counts.initRepeated += 1;
|
|
890
|
+
log(`[otaless] initialize for ${group} answered 10014 (a handshake a moment ago) - asked once more after the pause`);
|
|
891
|
+
try {
|
|
892
|
+
sent = await client.initialize(group, { token: acct.token }, deps.callerOf(who), 'after-pause');
|
|
893
|
+
}
|
|
894
|
+
catch (again) {
|
|
895
|
+
throw refused(again);
|
|
896
|
+
}
|
|
875
897
|
}
|
|
876
898
|
const id = text(sent.data?.mcpSessionId) ?? sent.session;
|
|
877
899
|
if (sent.data?.success === false || !id || !SESSION_ID.test(id)) {
|
|
878
900
|
counts.initRefused += 1;
|
|
879
901
|
log(`[otaless] initialize for ${group} gave no usable Mcp-Session-Id`);
|
|
880
|
-
|
|
902
|
+
// An answer, with no session in it - not one that did not come (`withSession`).
|
|
903
|
+
throw Object.assign(new OtalessError('the Otaless hotel backend gave no session', 200), {
|
|
904
|
+
noSession: true,
|
|
905
|
+
});
|
|
881
906
|
}
|
|
882
907
|
keep(acct, id);
|
|
883
908
|
return id;
|
|
@@ -920,7 +945,29 @@ export const createOtalessBookings = (deps) => {
|
|
|
920
945
|
}
|
|
921
946
|
counts.sessionRetried += 1;
|
|
922
947
|
sessions.delete(sessionKey(acct));
|
|
923
|
-
|
|
948
|
+
let again;
|
|
949
|
+
try {
|
|
950
|
+
again = await handshake(acct, who);
|
|
951
|
+
}
|
|
952
|
+
catch (err) {
|
|
953
|
+
// ⚠️ 4012, AND NO NEW SESSION (0.74.5, robin's demo 11-17): the 4012 stands - "Channel
|
|
954
|
+
// session expired for [shangrila]. Please re-login to this channel" - so the guest is
|
|
955
|
+
// asked to link that group (`linkFirst`), never told only that it was not booked. The
|
|
956
|
+
// 4012 is answered before the group is asked (the document's
|
|
957
|
+
// `requireMemberAndMcpSession`): nothing was ordered. A 401 (the account's own sign-in)
|
|
958
|
+
// and a group's own words for not linked are already said as those (`handshake`).
|
|
959
|
+
if (!(err instanceof OtalessError))
|
|
960
|
+
throw err;
|
|
961
|
+
// ⚠️ NOT A WORD ABOUT THE LINK (0.74.6, 总线程's review of 0.74.5, P3-2): a handshake held
|
|
962
|
+
// back by a limit of ours, or not answered at all, says nothing of the membership - as a
|
|
963
|
+
// read's does not (backend.ts `asMember`). Thrown as it came: the stay is "too many just
|
|
964
|
+
// now" or "did not answer" (`place`), the link left alone - no `expired`.
|
|
965
|
+
const noSession = err.noSession === true;
|
|
966
|
+
if (err instanceof OtalessBusy || (unanswered(err) && !noSession))
|
|
967
|
+
throw err;
|
|
968
|
+
const how = err.backendCode !== undefined ? `was refused (code ${err.backendCode})` : 'gave no session';
|
|
969
|
+
throw linkFirst(acct, `4012, and the new handshake ${how}`);
|
|
970
|
+
}
|
|
924
971
|
try {
|
|
925
972
|
const r = await call({ token: acct.token, session: again });
|
|
926
973
|
if (r.session && r.session !== again)
|
|
@@ -1703,6 +1750,12 @@ export const createOtalessBookings = (deps) => {
|
|
|
1703
1750
|
const code = text(w.originalOrderId) ?? '';
|
|
1704
1751
|
if (knownNamed(a, id, code))
|
|
1705
1752
|
return untouched(a, id, 'answered');
|
|
1753
|
+
// ⚠️ AN ORDER MADE AT THE GROUP SAYS THE BACKEND HOLDS ITS SESSION FOR THIS ACCOUNT (0.74.5,
|
|
1754
|
+
// 总线程 11-17: robin's AT-F2519E, booked on a link from before links were remembered, under
|
|
1755
|
+
// an account page saying "Link membership"): the account remembers the group as linked -
|
|
1756
|
+
// whatever is checked of the order below.
|
|
1757
|
+
// With the token it was booked with: an account signed in since is not the one (0.74.6, P3-4).
|
|
1758
|
+
deps.auth?.booked?.(a.acct.key, a.group, a.acct.token);
|
|
1706
1759
|
const page = text(w.checkoutUrl ?? undefined);
|
|
1707
1760
|
// ⚠️ "CONFIRMED" WITH A PAYMENT PAGE IS WAITING FOR ITS PAYMENT (questions
|
|
1708
1761
|
// #53, #61 (1) - 8's own example): paid is what 15 says, never this status.
|
|
@@ -1996,6 +2049,9 @@ export const createOtalessBookings = (deps) => {
|
|
|
1996
2049
|
// 8's step 1 (0.72.1): the group's terms asked for. Not sent at a group that asks
|
|
1997
2050
|
// for no terms - nor after the guest agreed to them: steps 2 and 3 carry the token.
|
|
1998
2051
|
...(a.groupTerms === 'ask' ? { termsRequired: true } : {}),
|
|
2052
|
+
// ⚠️ ACCOR: ITS COUNTRY, A LANGUAGE AND A CURRENCY, AS ITS ROOMS AND QUOTE (0.74.5 -
|
|
2053
|
+
// its /rooms refuses without them; 8 not tried on the real backend: it orders).
|
|
2054
|
+
...localeAsked(a.hotel.supplier ?? a.group, a.hotel.countryCode),
|
|
1999
2055
|
};
|
|
2000
2056
|
const cred8 = { token: cred.token, ...(session ? { session } : {}) };
|
|
2001
2057
|
const send = async (b) => {
|
|
@@ -2101,6 +2157,12 @@ export const createOtalessBookings = (deps) => {
|
|
|
2101
2157
|
failedStay(a, `${g.name} asked us to wait a moment before pricing it again, so nothing was booked - the guest can press Book again in a few seconds.`, 'group-wait')
|
|
2102
2158
|
: failedStay(a, `${g.name} did not price it again just now, so nothing was booked.`, 'unreachable'),
|
|
2103
2159
|
};
|
|
2160
|
+
// A handshake after a 4012 that did not answer (0.74.6, P3-2): nothing was ordered - 8 was
|
|
2161
|
+
// not sent again - and nothing is said of the link.
|
|
2162
|
+
if (err !== fromBook && unanswered(err) && !err.noSession)
|
|
2163
|
+
return {
|
|
2164
|
+
failed: failedStay(a, `${g.name} did not answer just now, so nothing was booked or charged - the guest can press Book again in a moment.`, 'unreachable'),
|
|
2165
|
+
};
|
|
2104
2166
|
if (err instanceof OtalessBusy)
|
|
2105
2167
|
return {
|
|
2106
2168
|
failed:
|
|
@@ -2391,9 +2453,12 @@ export const createOtalessBookings = (deps) => {
|
|
|
2391
2453
|
!Array.isArray(e.groups))
|
|
2392
2454
|
throw err;
|
|
2393
2455
|
stayRefusals.push(err);
|
|
2456
|
+
// ⚠️ WITH ITS CODE (0.74.5): the card says it in its own words, with the way to link or
|
|
2457
|
+
// sign in - the message is the model's ("…the guest presses Book again").
|
|
2458
|
+
const code = e.code === 'sign-in' ? (e.groups.length ? 'link-first' : 'sign-in') : 'signed-out';
|
|
2394
2459
|
return {
|
|
2395
2460
|
failed: {
|
|
2396
|
-
...failedStay(label, err.message),
|
|
2461
|
+
...failedStay(label, err.message, code),
|
|
2397
2462
|
...(e.groups.length ? { groups: [...e.groups] } : {}),
|
|
2398
2463
|
},
|
|
2399
2464
|
};
|
|
@@ -2985,6 +3050,9 @@ export const createOtalessBookings = (deps) => {
|
|
|
2985
3050
|
cancellable: true,
|
|
2986
3051
|
feeIsCap: true,
|
|
2987
3052
|
feeUnknown: true,
|
|
3053
|
+
// ⚠️ `rule` IS OURS, FOR THE MODEL (0.74.5): the card says this in its own words, never
|
|
3054
|
+
// under "the group's own words".
|
|
3055
|
+
termsNew: true,
|
|
2988
3056
|
};
|
|
2989
3057
|
// ⚠️ THE GROUP'S OWN TERMS, AS THEY CAME; ONLY WITHOUT THEM THE CAP
|
|
2990
3058
|
// (总线程 11-10). There is no dry run: what is kept is the group's to say
|