@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
package/dist/tools.js
CHANGED
|
@@ -4008,6 +4008,42 @@ const refusalAnswer = (deps, key, err) => {
|
|
|
4008
4008
|
* some hosts hand `_meta` to their model.
|
|
4009
4009
|
*/
|
|
4010
4010
|
export const TERMS_META_KEY = 'curless/terms';
|
|
4011
|
+
/**
|
|
4012
|
+
* The photographs of each room type the card's gallery opens, beside the answer (`_meta`):
|
|
4013
|
+
* `{ [hotelId]: { [roomTypeId]: string[] } }`, the cover first, once a type (never once a
|
|
4014
|
+
* rate) and only for a type with more than one. ⚠️ NEVER IN WHAT THE MODEL READS (robin
|
|
4015
|
+
* 11-19, 总线程): a Huazhu hotel has up to 84 room photographs, the model needs no address of
|
|
4016
|
+
* them - and only to a client that said it draws cards, as some hosts hand `_meta` to their
|
|
4017
|
+
* model. The card puts a list back as the room's `images` (card.ts `withKept`).
|
|
4018
|
+
*/
|
|
4019
|
+
export const ROOM_PHOTOS_META_KEY = 'curless/room-photos';
|
|
4020
|
+
/**
|
|
4021
|
+
* The hotel's own photographs for the page's strip (0.77.1), beside the answer (`_meta`):
|
|
4022
|
+
* `{ [hotelId]: { photos: string[], kinds: string[] } }` - the lead photograph (the one the
|
|
4023
|
+
* page shows above the name) first, then cover, outside, facilities, surroundings, meeting
|
|
4024
|
+
* rooms; `kinds[i]` is what `photos[i]` shows (`HotelPhotoKind`), for the card to name under
|
|
4025
|
+
* it. At most 30, always two or more. ⚠️ NEVER IN WHAT THE MODEL READS, and only to a client
|
|
4026
|
+
* that said it draws cards (as `ROOM_PHOTOS_META_KEY`).
|
|
4027
|
+
*/
|
|
4028
|
+
export const HOTEL_PHOTOS_META_KEY = 'curless/hotel-photos';
|
|
4029
|
+
/**
|
|
4030
|
+
* Where the hotel is, for the card's 「在地图中打开」 (0.77.1): `{ [hotelId]: { lat, lng } }`, the
|
|
4031
|
+
* supplier's own coordinates (Huazhu: China's GCJ-02). The card makes the map link itself. Beside
|
|
4032
|
+
* the answer, card clients only, never in what the model reads.
|
|
4033
|
+
*/
|
|
4034
|
+
export const HOTEL_GEO_META_KEY = 'curless/hotel-geo';
|
|
4035
|
+
/** What the hotel page tells the model of the hotel itself - the same fields, as words (`HotelFacts`). */
|
|
4036
|
+
const hotelFactsText = (f) => {
|
|
4037
|
+
if (!f)
|
|
4038
|
+
return '';
|
|
4039
|
+
const parts = [
|
|
4040
|
+
f.phone ? `phone ${f.phone.zh} (from abroad ${f.phone.en})` : '',
|
|
4041
|
+
f.openedYear ? `opened ${f.openedYear}` : '',
|
|
4042
|
+
f.renovatedYear ? `renovated ${f.renovatedYear}` : '',
|
|
4043
|
+
f.roomCount ? `${f.roomCount} rooms in all` : '',
|
|
4044
|
+
].filter(Boolean);
|
|
4045
|
+
return parts.length ? `About the hotel: ${parts.join(', ')}.` : '';
|
|
4046
|
+
};
|
|
4011
4047
|
/** The longest stretch of a group's refund terms put in the answer. */
|
|
4012
4048
|
const TERMS_TEXT_MAX = 2_000;
|
|
4013
4049
|
/**
|
|
@@ -4332,6 +4368,8 @@ const soldOutTypesOf = (detail, enough, wanted) => {
|
|
|
4332
4368
|
...(r.view ? { view: r.view } : {}),
|
|
4333
4369
|
...(r.window ? { window: r.window } : {}),
|
|
4334
4370
|
...(r.floor ? { floor: r.floor } : {}),
|
|
4371
|
+
...(r.wifi ? { wifi: true } : {}),
|
|
4372
|
+
...(r.extraBed ? { extraBed: true } : {}),
|
|
4335
4373
|
...(r.imageUrl ? { imageUrl: r.imageUrl } : {}),
|
|
4336
4374
|
// Some left, but not as many as were asked for.
|
|
4337
4375
|
...(left > 0 ? { left } : {}),
|
|
@@ -5269,6 +5307,8 @@ who) => {
|
|
|
5269
5307
|
// a chip that says something else in the guest's name.
|
|
5270
5308
|
label: `Compare ${hotelName(hotel.name)} with the other ${hotelName(hotel.city)} hotels`,
|
|
5271
5309
|
say: `Compare ${hotelName(hotel.name)} with the other ${hotelName(hotel.city)} hotels`,
|
|
5310
|
+
// (0.77.1: the card draws this one as its own action - see card.ts `isCompareChip` - and the
|
|
5311
|
+
// answer is unchanged, byte for byte: Otaless's surface is frozen.)
|
|
5272
5312
|
});
|
|
5273
5313
|
}
|
|
5274
5314
|
// The price order is not a suggestion any more: it is the list's own sort
|
|
@@ -7729,6 +7769,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7729
7769
|
...common(deps, key),
|
|
7730
7770
|
hotel: {
|
|
7731
7771
|
...h,
|
|
7772
|
+
// The hotel's own phone, years and room count: the model reads them (`HotelFacts`).
|
|
7773
|
+
...(detail.facts ?? {}),
|
|
7732
7774
|
summary: description.text,
|
|
7733
7775
|
fromNightly: h.fromNightly ? formatMoney(h.fromNightly) : undefined,
|
|
7734
7776
|
},
|
|
@@ -7737,6 +7779,20 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7737
7779
|
? { policies: policies.map((p) => ({ topic: p.topic, title: p.title })) }
|
|
7738
7780
|
: {}),
|
|
7739
7781
|
};
|
|
7782
|
+
const aboutSaid = hotelFactsText(detail.facts);
|
|
7783
|
+
// The photographs and the place, for the card alone (`HOTEL_PHOTOS_META_KEY`, `HOTEL_GEO_META_KEY`).
|
|
7784
|
+
const hotelMeta = ctx.drawsCards
|
|
7785
|
+
? {
|
|
7786
|
+
...(detail.hotelPhotos && detail.hotelPhotos.photos.length > 1
|
|
7787
|
+
? { [HOTEL_PHOTOS_META_KEY]: { [h.id]: detail.hotelPhotos } }
|
|
7788
|
+
: {}),
|
|
7789
|
+
...(detail.geo ? { [HOTEL_GEO_META_KEY]: { [h.id]: detail.geo } } : {}),
|
|
7790
|
+
}
|
|
7791
|
+
: {};
|
|
7792
|
+
const metaWith = (more = {}) => {
|
|
7793
|
+
const all = { ...hotelMeta, ...more };
|
|
7794
|
+
return Object.keys(all).length ? { meta: all } : {};
|
|
7795
|
+
};
|
|
7740
7796
|
// ⚠️ TO A CLIENT THAT DRAWS NO CARD, NO DATES IS TONIGHT, PRICED - AND SAID
|
|
7741
7797
|
// (robin 11-06, with 总线程 after RollingGo and robin's Manus run): the card
|
|
7742
7798
|
// fills in tonight itself, so a guest who can tap sees rooms at once; in
|
|
@@ -7764,6 +7820,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7764
7820
|
}
|
|
7765
7821
|
if (!stay) {
|
|
7766
7822
|
return {
|
|
7823
|
+
...metaWith(),
|
|
7767
7824
|
// ⚠️ THE FILTERS RIDE ALONG WITHOUT DATES: the card prices the dates
|
|
7768
7825
|
// itself and draws its chips from this answer, so a model that asked
|
|
7769
7826
|
// for breakfast before any night was named still has it asked.
|
|
@@ -7776,6 +7833,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7776
7833
|
text: [
|
|
7777
7834
|
`**${ctx.noCards ? withZh(h.name, h.names?.name, true) : h.name}** · ${[h.area, h.city].filter(Boolean).join(', ')}`,
|
|
7778
7835
|
description.fenced,
|
|
7836
|
+
aboutSaid,
|
|
7779
7837
|
'Rooms and prices need the dates - which nights is the guest staying?',
|
|
7780
7838
|
]
|
|
7781
7839
|
.filter(Boolean)
|
|
@@ -7806,6 +7864,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7806
7864
|
? `${detail.noRooms} ${askLater(!ctx.noCards)}`
|
|
7807
7865
|
: detail.noRooms;
|
|
7808
7866
|
return {
|
|
7867
|
+
...metaWith(),
|
|
7809
7868
|
structured: {
|
|
7810
7869
|
view: 'no-rooms',
|
|
7811
7870
|
...base,
|
|
@@ -7815,7 +7874,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7815
7874
|
...(detail.noRoomsArgs ? { noRoomsArgs: detail.noRoomsArgs } : {}),
|
|
7816
7875
|
...flex.structured,
|
|
7817
7876
|
},
|
|
7818
|
-
text: [said ?? 'Nothing is available for those nights.', flex.text]
|
|
7877
|
+
text: [said ?? 'Nothing is available for those nights.', flex.text, aboutSaid]
|
|
7819
7878
|
.filter(Boolean)
|
|
7820
7879
|
.join(' '),
|
|
7821
7880
|
};
|
|
@@ -7823,6 +7882,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7823
7882
|
const enough = detail.rooms.filter((r) => r.roomsLeft >= roomsWanted);
|
|
7824
7883
|
if (enough.length === 0) {
|
|
7825
7884
|
return {
|
|
7885
|
+
...metaWith(),
|
|
7826
7886
|
structured: {
|
|
7827
7887
|
view: 'no-rooms',
|
|
7828
7888
|
...base,
|
|
@@ -7836,6 +7896,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7836
7896
|
text: [
|
|
7837
7897
|
`No room type at ${h.name} has ${roomsWanted} left for ${stay.checkIn} to ${stay.checkOut}.`,
|
|
7838
7898
|
flex.text,
|
|
7899
|
+
aboutSaid,
|
|
7839
7900
|
]
|
|
7840
7901
|
.filter(Boolean)
|
|
7841
7902
|
.join(' '),
|
|
@@ -7916,7 +7977,12 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7916
7977
|
? null
|
|
7917
7978
|
: weekendOf(stay.checkIn, stay.checkOut, todayOfHotel(h, deps.trips.now()));
|
|
7918
7979
|
const weekend = weekendFor ? weekendWords(weekendFor) : '';
|
|
7980
|
+
// Each listed type's photographs, for the card alone (`ROOM_PHOTOS_META_KEY`).
|
|
7981
|
+
const galleries = Object.fromEntries(Object.entries(detail.roomPhotos ?? {}).filter(([id, list]) => list.length > 1 && enough.some((r) => (r.roomType?.id ?? r.id) === id)));
|
|
7919
7982
|
return {
|
|
7983
|
+
...metaWith(ctx.drawsCards && Object.keys(galleries).length
|
|
7984
|
+
? { [ROOM_PHOTOS_META_KEY]: { [h.id]: galleries } }
|
|
7985
|
+
: {}),
|
|
7920
7986
|
structured: {
|
|
7921
7987
|
view: 'hotel',
|
|
7922
7988
|
...base,
|
|
@@ -7941,6 +8007,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7941
8007
|
weekend,
|
|
7942
8008
|
memberRates?.said ?? '',
|
|
7943
8009
|
notBookable,
|
|
8010
|
+
aboutSaid,
|
|
7944
8011
|
...(detail.priceNotes ?? []),
|
|
7945
8012
|
...roomsText(ctx.noCards ? withZh(h.name, h.names?.name, true) : h.name, byTheHour
|
|
7946
8013
|
? (rs) => `${rs.length} ${rs.length === 1 ? 'room' : 'rooms'} by the hour for today, ${stay.checkIn}, ${stay.guests} guests`
|