@curless/hotel-storefront 0.76.4 → 0.77.1
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/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/huazhu/backend.d.ts +5 -0
- package/dist/huazhu/backend.d.ts.map +1 -1
- package/dist/huazhu/backend.js +54 -1
- package/dist/huazhu/backend.js.map +1 -1
- package/dist/huazhu/catalog.d.ts +42 -2
- package/dist/huazhu/catalog.d.ts.map +1 -1
- package/dist/huazhu/catalog.js +192 -4
- package/dist/huazhu/catalog.js.map +1 -1
- package/dist/huazhu/fake.d.ts +13 -1
- package/dist/huazhu/fake.d.ts.map +1 -1
- package/dist/huazhu/fake.js +96 -0
- package/dist/huazhu/fake.js.map +1 -1
- package/dist/huazhu/sandbox.d.ts.map +1 -1
- package/dist/huazhu/sandbox.js +101 -8
- package/dist/huazhu/sandbox.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/tools.d.ts +24 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +68 -1
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.generated.js","sourceRoot":"","sources":["../src/card.generated.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wEAAwE;AACxE,gFAAgF;AAChF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAW,MAAM,CAAC,IAAI,CAChD,
|
|
1
|
+
{"version":3,"file":"card.generated.js","sourceRoot":"","sources":["../src/card.generated.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wEAAwE;AACxE,gFAAgF;AAChF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAW,MAAM,CAAC,IAAI,CAChD,05zmDAA05zmD,EAC15zmD,QAAQ,CACT,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEnB,6GAA6G;AAC7G,MAAM,CAAC,MAAM,qBAAqB,GAChC,kEAAkE,CAAC;AAErE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,qBAAqB,GAChC,iLAAiL,CAAC"}
|
package/dist/huazhu/backend.d.ts
CHANGED
|
@@ -83,6 +83,11 @@ export declare const newPublicCode: (taken: (code: string) => boolean) => string
|
|
|
83
83
|
export declare const PRICE_ALL = 20;
|
|
84
84
|
/** Hotels whose product lists are read to find which sell rooms by the hour today. */
|
|
85
85
|
export declare const HOURLY_SCAN = 60;
|
|
86
|
+
/**
|
|
87
|
+
* Huazhu's `floorPlace` as the card says it: "9", or "2-5" for a range - nothing for empty, 0 or
|
|
88
|
+
* anything else (0.77.1). A range written backwards is not read.
|
|
89
|
+
*/
|
|
90
|
+
export declare const floorOf: (raw: string | undefined) => string | undefined;
|
|
86
91
|
/**
|
|
87
92
|
* A product as a guest is shown it - Huazhu's own words, but for three that are its
|
|
88
93
|
* own bookkeeping (0.75.1, robin 11-18, on 华住生产 - his own exceptions to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/huazhu/backend.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,YAAY,EASlB,MAAM,eAAe,CAAC;AAavB,OAAO,EAEL,KAAK,aAAa,EAKnB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,QAAQ,EAAiC,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAGL,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAuBV,KAAK,EAML,UAAU,EAIX,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,YAAY,EAIjB,KAAK,UAAU,EAEf,KAAK,aAAa,EAGnB,MAAM,eAAe,CAAC;AAcvB,OAAO,
|
|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MAX_ROOMS_PER_LINE, quoteLineKey } from '../trip.js';
|
|
13
13
|
import { IN_REQUEST_AT_MS, NOT_FOUND, StoreWriteError, nextCheckAt, statusOf, } from './bookings.js';
|
|
14
14
|
import { describePolicy, feeFor, freeUntilOf, nightAuditOf, parseCancelPolicy, penaltyAt, phasesOf, refundableFrom, stepsOf, } from './cancel-policy.js';
|
|
15
|
-
import { haystackOf, inPlace, namesOf, roomPhoto, toHotel } from './catalog.js';
|
|
15
|
+
import { haystackOf, hotelFacts, hotelGeo, hotelPhotos, inPlace, namesOf, roomPhoto, roomPhotos, toHotel, } from './catalog.js';
|
|
16
16
|
import { HuazhuRefusal, HuazhuTooBusy, HuazhuUnreachable } from './client.js';
|
|
17
17
|
import { bedNameEn, isChannelRateName, offerNameEn, rateNameEn, roomNameEn } from './english.js';
|
|
18
18
|
import { rateLabels } from './labels.js';
|
|
@@ -105,6 +105,19 @@ const WINDOW_ZH = {
|
|
|
105
105
|
'3': '无窗',
|
|
106
106
|
'4': '内景窗',
|
|
107
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Huazhu's `floorPlace` as the card says it: "9", or "2-5" for a range - nothing for empty, 0 or
|
|
110
|
+
* anything else (0.77.1). A range written backwards is not read.
|
|
111
|
+
*/
|
|
112
|
+
export const floorOf = (raw) => {
|
|
113
|
+
const f = (raw ?? '').trim();
|
|
114
|
+
const range = /^(\d{1,3})\s*[-–—~~]\s*(\d{1,3})$/.exec(f);
|
|
115
|
+
const from = Number(range?.[1] ?? f);
|
|
116
|
+
const to = Number(range?.[2] ?? f);
|
|
117
|
+
if (!/^\d{1,3}$/.test(range ? String(range[1]) : f) || !(from > 0) || !(to >= from))
|
|
118
|
+
return undefined;
|
|
119
|
+
return to === from ? String(from) : `${from}-${to}`;
|
|
120
|
+
};
|
|
108
121
|
/** A rate's meal in Chinese, by its code; room only is 不含早. */
|
|
109
122
|
const MEAL_ZH = {
|
|
110
123
|
BB: '含早',
|
|
@@ -1023,6 +1036,36 @@ export const createHuazhuHotels = (opts) => {
|
|
|
1023
1036
|
freeCancellationLocalIso: localIsoAt(held, opts.tz),
|
|
1024
1037
|
};
|
|
1025
1038
|
};
|
|
1039
|
+
/**
|
|
1040
|
+
* Each listed room type's photographs, once a type (`HotelDetail.roomPhotos`): only a type
|
|
1041
|
+
* with more than the one the room already carries as `imageUrl`.
|
|
1042
|
+
*/
|
|
1043
|
+
const galleriesOf = (h, rooms) => {
|
|
1044
|
+
const out = {};
|
|
1045
|
+
for (const r of rooms) {
|
|
1046
|
+
const id = r.roomType?.id;
|
|
1047
|
+
if (!id || id in out)
|
|
1048
|
+
continue;
|
|
1049
|
+
const list = roomPhotos(h, id);
|
|
1050
|
+
if (list.length > 1)
|
|
1051
|
+
out[id] = list;
|
|
1052
|
+
}
|
|
1053
|
+
return Object.keys(out).length ? { roomPhotos: out } : {};
|
|
1054
|
+
};
|
|
1055
|
+
/**
|
|
1056
|
+
* What the record says of the hotel itself, for its page alone (0.77.1): its facts (for the
|
|
1057
|
+
* model and the card), its photographs and where it is (for the card alone - see `HotelDetail`).
|
|
1058
|
+
*/
|
|
1059
|
+
const aboutOf = (h) => {
|
|
1060
|
+
const facts = hotelFacts(h, now());
|
|
1061
|
+
const photos = hotelPhotos(h);
|
|
1062
|
+
const geo = hotelGeo(h);
|
|
1063
|
+
return {
|
|
1064
|
+
...(Object.keys(facts).length ? { facts } : {}),
|
|
1065
|
+
...(photos ? { hotelPhotos: photos } : {}),
|
|
1066
|
+
...(geo ? { geo } : {}),
|
|
1067
|
+
};
|
|
1068
|
+
};
|
|
1026
1069
|
const toRoom = (h, p, stay) => {
|
|
1027
1070
|
const s = p.res;
|
|
1028
1071
|
const cur = s.currency;
|
|
@@ -1048,6 +1091,11 @@ export const createHuazhuHotels = (opts) => {
|
|
|
1048
1091
|
sleeps: s.sleeps,
|
|
1049
1092
|
...(rt?.hotelArea ? { sizeSqm: rt.hotelArea } : {}),
|
|
1050
1093
|
...(beds.length ? { beds: beds.join(' / ') } : {}),
|
|
1094
|
+
// 0.77.1: only what the record says yes to - never "no Wi-Fi", never "no extra bed". ⚠️ NOT
|
|
1095
|
+
// `hasSmokeFree` (Ctrip says otherwise), `invoiceType` or `cleanLevel` - robin 11-19.
|
|
1096
|
+
...(rt?.isADSLWifi === '1' ? { wifi: true } : {}),
|
|
1097
|
+
...(floorOf(rt?.floorPlace) ? { floor: floorOf(rt?.floorPlace) } : {}),
|
|
1098
|
+
...(rt?.isCanAddBed === '1' ? { extraBed: true } : {}),
|
|
1051
1099
|
...(rt?.isHasWindow && (en ? WINDOW : WINDOW_ZH)[rt.isHasWindow]
|
|
1052
1100
|
? { view: (en ? WINDOW : WINDOW_ZH)[rt.isHasWindow] }
|
|
1053
1101
|
: {}),
|
|
@@ -3978,6 +4026,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
3978
4026
|
return null;
|
|
3979
4027
|
const detail = {
|
|
3980
4028
|
hotel: withSells(toHotel(raw, view, now()), await sellsHourlyOf(raw.hotelId)),
|
|
4029
|
+
...aboutOf(raw),
|
|
3981
4030
|
};
|
|
3982
4031
|
if (!stay)
|
|
3983
4032
|
return detail;
|
|
@@ -4007,6 +4056,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
4007
4056
|
...detail,
|
|
4008
4057
|
stay,
|
|
4009
4058
|
rooms,
|
|
4059
|
+
...galleriesOf(raw, rooms),
|
|
4010
4060
|
...(soldOut.length ? { soldOut } : {}),
|
|
4011
4061
|
...(rooms.length === 0 ? noRoomsOf(noRoomsWhy(priced, stay, 1)) : {}),
|
|
4012
4062
|
};
|
|
@@ -4025,6 +4075,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
4025
4075
|
catch (err) {
|
|
4026
4076
|
return {
|
|
4027
4077
|
hotel,
|
|
4078
|
+
...aboutOf(raw),
|
|
4028
4079
|
stay,
|
|
4029
4080
|
...noRoomsOf({
|
|
4030
4081
|
why: `Huazhu could not be asked for this hotel's rooms by the hour just now (${err instanceof HuazhuRefusal ? err.huazhuMessage : 'no answer'}). Try again in a moment.`,
|
|
@@ -4038,8 +4089,10 @@ export const createHuazhuHotels = (opts) => {
|
|
|
4038
4089
|
.sort((a, b) => a.stayTotal.minor - b.stayTotal.minor);
|
|
4039
4090
|
return {
|
|
4040
4091
|
hotel,
|
|
4092
|
+
...aboutOf(raw),
|
|
4041
4093
|
stay,
|
|
4042
4094
|
rooms,
|
|
4095
|
+
...galleriesOf(raw, rooms),
|
|
4043
4096
|
...(rooms.length === 0 ? noRoomsOf(hourlyNoRoomsWhy(priced, guests)) : {}),
|
|
4044
4097
|
};
|
|
4045
4098
|
},
|