@curless/hotel-storefront 0.77.0 → 0.77.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/tools.js CHANGED
@@ -4017,6 +4017,33 @@ export const TERMS_META_KEY = 'curless/terms';
4017
4017
  * model. The card puts a list back as the room's `images` (card.ts `withKept`).
4018
4018
  */
4019
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
+ };
4020
4047
  /** The longest stretch of a group's refund terms put in the answer. */
4021
4048
  const TERMS_TEXT_MAX = 2_000;
4022
4049
  /**
@@ -4341,6 +4368,8 @@ const soldOutTypesOf = (detail, enough, wanted) => {
4341
4368
  ...(r.view ? { view: r.view } : {}),
4342
4369
  ...(r.window ? { window: r.window } : {}),
4343
4370
  ...(r.floor ? { floor: r.floor } : {}),
4371
+ ...(r.wifi ? { wifi: true } : {}),
4372
+ ...(r.extraBed ? { extraBed: true } : {}),
4344
4373
  ...(r.imageUrl ? { imageUrl: r.imageUrl } : {}),
4345
4374
  // Some left, but not as many as were asked for.
4346
4375
  ...(left > 0 ? { left } : {}),
@@ -5278,6 +5307,8 @@ who) => {
5278
5307
  // a chip that says something else in the guest's name.
5279
5308
  label: `Compare ${hotelName(hotel.name)} with the other ${hotelName(hotel.city)} hotels`,
5280
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.)
5281
5312
  });
5282
5313
  }
5283
5314
  // The price order is not a suggestion any more: it is the list's own sort
@@ -7738,6 +7769,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7738
7769
  ...common(deps, key),
7739
7770
  hotel: {
7740
7771
  ...h,
7772
+ // The hotel's own phone, years and room count: the model reads them (`HotelFacts`).
7773
+ ...(detail.facts ?? {}),
7741
7774
  summary: description.text,
7742
7775
  fromNightly: h.fromNightly ? formatMoney(h.fromNightly) : undefined,
7743
7776
  },
@@ -7746,6 +7779,20 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7746
7779
  ? { policies: policies.map((p) => ({ topic: p.topic, title: p.title })) }
7747
7780
  : {}),
7748
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
+ };
7749
7796
  // ⚠️ TO A CLIENT THAT DRAWS NO CARD, NO DATES IS TONIGHT, PRICED - AND SAID
7750
7797
  // (robin 11-06, with 总线程 after RollingGo and robin's Manus run): the card
7751
7798
  // fills in tonight itself, so a guest who can tap sees rooms at once; in
@@ -7773,6 +7820,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7773
7820
  }
7774
7821
  if (!stay) {
7775
7822
  return {
7823
+ ...metaWith(),
7776
7824
  // ⚠️ THE FILTERS RIDE ALONG WITHOUT DATES: the card prices the dates
7777
7825
  // itself and draws its chips from this answer, so a model that asked
7778
7826
  // for breakfast before any night was named still has it asked.
@@ -7785,6 +7833,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7785
7833
  text: [
7786
7834
  `**${ctx.noCards ? withZh(h.name, h.names?.name, true) : h.name}** · ${[h.area, h.city].filter(Boolean).join(', ')}`,
7787
7835
  description.fenced,
7836
+ aboutSaid,
7788
7837
  'Rooms and prices need the dates - which nights is the guest staying?',
7789
7838
  ]
7790
7839
  .filter(Boolean)
@@ -7815,6 +7864,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7815
7864
  ? `${detail.noRooms} ${askLater(!ctx.noCards)}`
7816
7865
  : detail.noRooms;
7817
7866
  return {
7867
+ ...metaWith(),
7818
7868
  structured: {
7819
7869
  view: 'no-rooms',
7820
7870
  ...base,
@@ -7824,7 +7874,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7824
7874
  ...(detail.noRoomsArgs ? { noRoomsArgs: detail.noRoomsArgs } : {}),
7825
7875
  ...flex.structured,
7826
7876
  },
7827
- text: [said ?? 'Nothing is available for those nights.', flex.text]
7877
+ text: [said ?? 'Nothing is available for those nights.', flex.text, aboutSaid]
7828
7878
  .filter(Boolean)
7829
7879
  .join(' '),
7830
7880
  };
@@ -7832,6 +7882,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7832
7882
  const enough = detail.rooms.filter((r) => r.roomsLeft >= roomsWanted);
7833
7883
  if (enough.length === 0) {
7834
7884
  return {
7885
+ ...metaWith(),
7835
7886
  structured: {
7836
7887
  view: 'no-rooms',
7837
7888
  ...base,
@@ -7845,6 +7896,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7845
7896
  text: [
7846
7897
  `No room type at ${h.name} has ${roomsWanted} left for ${stay.checkIn} to ${stay.checkOut}.`,
7847
7898
  flex.text,
7899
+ aboutSaid,
7848
7900
  ]
7849
7901
  .filter(Boolean)
7850
7902
  .join(' '),
@@ -7928,8 +7980,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7928
7980
  // Each listed type's photographs, for the card alone (`ROOM_PHOTOS_META_KEY`).
7929
7981
  const galleries = Object.fromEntries(Object.entries(detail.roomPhotos ?? {}).filter(([id, list]) => list.length > 1 && enough.some((r) => (r.roomType?.id ?? r.id) === id)));
7930
7982
  return {
7931
- ...(ctx.drawsCards && Object.keys(galleries).length
7932
- ? { meta: { [ROOM_PHOTOS_META_KEY]: { [h.id]: galleries } } }
7983
+ ...metaWith(ctx.drawsCards && Object.keys(galleries).length
7984
+ ? { [ROOM_PHOTOS_META_KEY]: { [h.id]: galleries } }
7933
7985
  : {}),
7934
7986
  structured: {
7935
7987
  view: 'hotel',
@@ -7955,6 +8007,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7955
8007
  weekend,
7956
8008
  memberRates?.said ?? '',
7957
8009
  notBookable,
8010
+ aboutSaid,
7958
8011
  ...(detail.priceNotes ?? []),
7959
8012
  ...roomsText(ctx.noCards ? withZh(h.name, h.names?.name, true) : h.name, byTheHour
7960
8013
  ? (rs) => `${rs.length} ${rs.length === 1 ? 'room' : 'rooms'} by the hour for today, ${stay.checkIn}, ${stay.guests} guests`