@curless/hotel-storefront 0.85.0 → 0.87.0
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/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/tools/accept-terms.d.ts +4 -0
- package/dist/tools/accept-terms.d.ts.map +1 -0
- package/dist/tools/accept-terms.js +26 -0
- package/dist/tools/accept-terms.js.map +1 -0
- package/dist/tools/add-booking-addon.d.ts +4 -0
- package/dist/tools/add-booking-addon.d.ts.map +1 -0
- package/dist/tools/add-booking-addon.js +44 -0
- package/dist/tools/add-booking-addon.js.map +1 -0
- package/dist/tools/add-to-trip.d.ts +4 -0
- package/dist/tools/add-to-trip.d.ts.map +1 -0
- package/dist/tools/add-to-trip.js +49 -0
- package/dist/tools/add-to-trip.js.map +1 -0
- package/dist/tools/all-tools.d.ts +19124 -0
- package/dist/tools/all-tools.d.ts.map +1 -0
- package/dist/tools/all-tools.js +43 -0
- package/dist/tools/all-tools.js.map +1 -0
- package/dist/tools/answer.d.ts +3 -0
- package/dist/tools/answer.d.ts.map +1 -0
- package/dist/tools/answer.js +104 -0
- package/dist/tools/answer.js.map +1 -0
- package/dist/tools/args.d.ts +149 -0
- package/dist/tools/args.d.ts.map +1 -0
- package/dist/tools/args.js +176 -0
- package/dist/tools/args.js.map +1 -0
- package/dist/tools/base-output-schemas.d.ts +3 -0
- package/dist/tools/base-output-schemas.d.ts.map +1 -0
- package/dist/tools/base-output-schemas.js +396 -0
- package/dist/tools/base-output-schemas.js.map +1 -0
- package/dist/tools/book-picked.d.ts +4 -0
- package/dist/tools/book-picked.d.ts.map +1 -0
- package/dist/tools/book-picked.js +14 -0
- package/dist/tools/book-picked.js.map +1 -0
- package/dist/tools/booking-answer.d.ts +24 -0
- package/dist/tools/booking-answer.d.ts.map +1 -0
- package/dist/tools/booking-answer.js +567 -0
- package/dist/tools/booking-answer.js.map +1 -0
- package/dist/tools/buy-shop-item.d.ts +4 -0
- package/dist/tools/buy-shop-item.d.ts.map +1 -0
- package/dist/tools/buy-shop-item.js +45 -0
- package/dist/tools/buy-shop-item.js.map +1 -0
- package/dist/tools/call.d.ts +11 -0
- package/dist/tools/call.d.ts.map +1 -0
- package/dist/tools/call.js +2 -0
- package/dist/tools/call.js.map +1 -0
- package/dist/tools/cancel-facts.d.ts +281 -0
- package/dist/tools/cancel-facts.d.ts.map +1 -0
- package/dist/tools/cancel-facts.js +309 -0
- package/dist/tools/cancel-facts.js.map +1 -0
- package/dist/tools/cancel.d.ts +4 -0
- package/dist/tools/cancel.d.ts.map +1 -0
- package/dist/tools/cancel.js +415 -0
- package/dist/tools/cancel.js.map +1 -0
- package/dist/tools/capability-adjust.d.ts +31 -0
- package/dist/tools/capability-adjust.d.ts.map +1 -0
- package/dist/tools/capability-adjust.js +299 -0
- package/dist/tools/capability-adjust.js.map +1 -0
- package/dist/tools/card-addons.d.ts +4 -0
- package/dist/tools/card-addons.d.ts.map +1 -0
- package/dist/tools/card-addons.js +76 -0
- package/dist/tools/card-addons.js.map +1 -0
- package/dist/tools/change-booking.d.ts +4 -0
- package/dist/tools/change-booking.d.ts.map +1 -0
- package/dist/tools/change-booking.js +145 -0
- package/dist/tools/change-booking.js.map +1 -0
- package/dist/tools/clear-trip.d.ts +4 -0
- package/dist/tools/clear-trip.d.ts.map +1 -0
- package/dist/tools/clear-trip.js +10 -0
- package/dist/tools/clear-trip.js.map +1 -0
- package/dist/tools/compare.d.ts +4 -0
- package/dist/tools/compare.d.ts.map +1 -0
- package/dist/tools/compare.js +114 -0
- package/dist/tools/compare.js.map +1 -0
- package/dist/tools/current-trip.d.ts +70 -0
- package/dist/tools/current-trip.d.ts.map +1 -0
- package/dist/tools/current-trip.js +269 -0
- package/dist/tools/current-trip.js.map +1 -0
- package/dist/tools/deps.d.ts +229 -0
- package/dist/tools/deps.d.ts.map +1 -0
- package/dist/tools/deps.js +2 -0
- package/dist/tools/deps.js.map +1 -0
- package/dist/tools/follow-ups.d.ts +120 -0
- package/dist/tools/follow-ups.d.ts.map +1 -0
- package/dist/tools/follow-ups.js +369 -0
- package/dist/tools/follow-ups.js.map +1 -0
- package/dist/tools/forget-preferences.d.ts +4 -0
- package/dist/tools/forget-preferences.d.ts.map +1 -0
- package/dist/tools/forget-preferences.js +24 -0
- package/dist/tools/forget-preferences.js.map +1 -0
- package/dist/tools/get-hotel.d.ts +4 -0
- package/dist/tools/get-hotel.d.ts.map +1 -0
- package/dist/tools/get-hotel.js +350 -0
- package/dist/tools/get-hotel.js.map +1 -0
- package/dist/tools/hotel-choices.d.ts +132 -0
- package/dist/tools/hotel-choices.d.ts.map +1 -0
- package/dist/tools/hotel-choices.js +587 -0
- package/dist/tools/hotel-choices.js.map +1 -0
- package/dist/tools/itinerary.d.ts +4 -0
- package/dist/tools/itinerary.d.ts.map +1 -0
- package/dist/tools/itinerary.js +158 -0
- package/dist/tools/itinerary.js.map +1 -0
- package/dist/tools/list-booking-addons.d.ts +4 -0
- package/dist/tools/list-booking-addons.d.ts.map +1 -0
- package/dist/tools/list-booking-addons.js +21 -0
- package/dist/tools/list-booking-addons.js.map +1 -0
- package/dist/tools/list-bookings.d.ts +4 -0
- package/dist/tools/list-bookings.d.ts.map +1 -0
- package/dist/tools/list-bookings.js +119 -0
- package/dist/tools/list-bookings.js.map +1 -0
- package/dist/tools/list-extras.d.ts +4 -0
- package/dist/tools/list-extras.d.ts.map +1 -0
- package/dist/tools/list-extras.js +90 -0
- package/dist/tools/list-extras.js.map +1 -0
- package/dist/tools/list-hotels-ask.d.ts +133 -0
- package/dist/tools/list-hotels-ask.d.ts.map +1 -0
- package/dist/tools/list-hotels-ask.js +326 -0
- package/dist/tools/list-hotels-ask.js.map +1 -0
- package/dist/tools/list-hotels-empty.d.ts +5 -0
- package/dist/tools/list-hotels-empty.d.ts.map +1 -0
- package/dist/tools/list-hotels-empty.js +130 -0
- package/dist/tools/list-hotels-empty.js.map +1 -0
- package/dist/tools/list-hotels-home.d.ts +9 -0
- package/dist/tools/list-hotels-home.d.ts.map +1 -0
- package/dist/tools/list-hotels-home.js +181 -0
- package/dist/tools/list-hotels-home.js.map +1 -0
- package/dist/tools/list-hotels-page.d.ts +43 -0
- package/dist/tools/list-hotels-page.d.ts.map +1 -0
- package/dist/tools/list-hotels-page.js +344 -0
- package/dist/tools/list-hotels-page.js.map +1 -0
- package/dist/tools/list-hotels.d.ts +4 -0
- package/dist/tools/list-hotels.d.ts.map +1 -0
- package/dist/tools/list-hotels.js +24 -0
- package/dist/tools/list-hotels.js.map +1 -0
- package/dist/tools/list-shop-items.d.ts +4 -0
- package/dist/tools/list-shop-items.d.ts.map +1 -0
- package/dist/tools/list-shop-items.js +34 -0
- package/dist/tools/list-shop-items.js.map +1 -0
- package/dist/tools/list-shop-orders.d.ts +4 -0
- package/dist/tools/list-shop-orders.d.ts.map +1 -0
- package/dist/tools/list-shop-orders.js +22 -0
- package/dist/tools/list-shop-orders.js.map +1 -0
- package/dist/tools/look-up.d.ts +4 -0
- package/dist/tools/look-up.d.ts.map +1 -0
- package/dist/tools/look-up.js +207 -0
- package/dist/tools/look-up.js.map +1 -0
- package/dist/tools/output-schemas.d.ts +645 -0
- package/dist/tools/output-schemas.d.ts.map +1 -0
- package/dist/tools/output-schemas.js +503 -0
- package/dist/tools/output-schemas.js.map +1 -0
- package/dist/tools/paid-lines.d.ts +718 -0
- package/dist/tools/paid-lines.d.ts.map +1 -0
- package/dist/tools/paid-lines.js +359 -0
- package/dist/tools/paid-lines.js.map +1 -0
- package/dist/tools/pay-with-union-pay.d.ts +4 -0
- package/dist/tools/pay-with-union-pay.d.ts.map +1 -0
- package/dist/tools/pay-with-union-pay.js +112 -0
- package/dist/tools/pay-with-union-pay.js.map +1 -0
- package/dist/tools/payment-words.d.ts +269 -0
- package/dist/tools/payment-words.d.ts.map +1 -0
- package/dist/tools/payment-words.js +365 -0
- package/dist/tools/payment-words.js.map +1 -0
- package/dist/tools/pick-room.d.ts +4 -0
- package/dist/tools/pick-room.d.ts.map +1 -0
- package/dist/tools/pick-room.js +23 -0
- package/dist/tools/pick-room.js.map +1 -0
- package/dist/tools/policies.d.ts +4 -0
- package/dist/tools/policies.d.ts.map +1 -0
- package/dist/tools/policies.js +74 -0
- package/dist/tools/policies.js.map +1 -0
- package/dist/tools/pricing.d.ts +55 -0
- package/dist/tools/pricing.d.ts.map +1 -0
- package/dist/tools/pricing.js +260 -0
- package/dist/tools/pricing.js.map +1 -0
- package/dist/tools/put-room-line.d.ts +12 -0
- package/dist/tools/put-room-line.d.ts.map +1 -0
- package/dist/tools/put-room-line.js +347 -0
- package/dist/tools/put-room-line.js.map +1 -0
- package/dist/tools/quote-card.d.ts +234 -0
- package/dist/tools/quote-card.d.ts.map +1 -0
- package/dist/tools/quote-card.js +375 -0
- package/dist/tools/quote-card.js.map +1 -0
- package/dist/tools/refund-booking.d.ts +4 -0
- package/dist/tools/refund-booking.d.ts.map +1 -0
- package/dist/tools/refund-booking.js +112 -0
- package/dist/tools/refund-booking.js.map +1 -0
- package/dist/tools/request-booking.d.ts +4 -0
- package/dist/tools/request-booking.d.ts.map +1 -0
- package/dist/tools/request-booking.js +5 -0
- package/dist/tools/request-booking.js.map +1 -0
- package/dist/tools/request-words.d.ts +238 -0
- package/dist/tools/request-words.d.ts.map +1 -0
- package/dist/tools/request-words.js +487 -0
- package/dist/tools/request-words.js.map +1 -0
- package/dist/tools/room-choices.d.ts +64 -0
- package/dist/tools/room-choices.d.ts.map +1 -0
- package/dist/tools/room-choices.js +374 -0
- package/dist/tools/room-choices.js.map +1 -0
- package/dist/tools/session-notes.d.ts +164 -0
- package/dist/tools/session-notes.d.ts.map +1 -0
- package/dist/tools/session-notes.js +412 -0
- package/dist/tools/session-notes.js.map +1 -0
- package/dist/tools/sign-in.d.ts +4 -0
- package/dist/tools/sign-in.d.ts.map +1 -0
- package/dist/tools/sign-in.js +72 -0
- package/dist/tools/sign-in.js.map +1 -0
- package/dist/tools/sign-out.d.ts +4 -0
- package/dist/tools/sign-out.d.ts.map +1 -0
- package/dist/tools/sign-out.js +13 -0
- package/dist/tools/sign-out.js.map +1 -0
- package/dist/tools/terms-answer.d.ts +114 -0
- package/dist/tools/terms-answer.d.ts.map +1 -0
- package/dist/tools/terms-answer.js +492 -0
- package/dist/tools/terms-answer.js.map +1 -0
- package/dist/tools/tool-defs-account.d.ts +80 -0
- package/dist/tools/tool-defs-account.d.ts.map +1 -0
- package/dist/tools/tool-defs-account.js +65 -0
- package/dist/tools/tool-defs-account.js.map +1 -0
- package/dist/tools/tool-defs-addons.d.ts +251 -0
- package/dist/tools/tool-defs-addons.d.ts.map +1 -0
- package/dist/tools/tool-defs-addons.js +198 -0
- package/dist/tools/tool-defs-addons.js.map +1 -0
- package/dist/tools/tool-defs-booking.d.ts +410 -0
- package/dist/tools/tool-defs-booking.d.ts.map +1 -0
- package/dist/tools/tool-defs-booking.js +285 -0
- package/dist/tools/tool-defs-booking.js.map +1 -0
- package/dist/tools/tool-defs-browse.d.ts +444 -0
- package/dist/tools/tool-defs-browse.d.ts.map +1 -0
- package/dist/tools/tool-defs-browse.js +307 -0
- package/dist/tools/tool-defs-browse.js.map +1 -0
- package/dist/tools/tool-defs-trip.d.ts +136 -0
- package/dist/tools/tool-defs-trip.d.ts.map +1 -0
- package/dist/tools/tool-defs-trip.js +79 -0
- package/dist/tools/tool-defs-trip.js.map +1 -0
- package/dist/tools/tool-env.d.ts +64 -0
- package/dist/tools/tool-env.d.ts.map +1 -0
- package/dist/tools/tool-env.js +49 -0
- package/dist/tools/tool-env.js.map +1 -0
- package/dist/tools/tool-set.d.ts +1425 -0
- package/dist/tools/tool-set.d.ts.map +1 -0
- package/dist/tools/tool-set.js +244 -0
- package/dist/tools/tool-set.js.map +1 -0
- package/dist/tools/view-trip.d.ts +4 -0
- package/dist/tools/view-trip.d.ts.map +1 -0
- package/dist/tools/view-trip.js +7 -0
- package/dist/tools/view-trip.js.map +1 -0
- package/dist/tools.d.ts +13 -2089
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +11 -10685
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Booking, DateOption, HotelDetail, HotelFacts, Room, Stay, TermsToAgree } from '../types.js';
|
|
2
|
+
import type { ToolContext, ToolDeps } from './deps.js';
|
|
3
|
+
/**
|
|
4
|
+
* The card's copy of the terms to agree to, beside the answer (`_meta`).
|
|
5
|
+
*
|
|
6
|
+
* ⚠️ THE TERMS' REF AND FULL TEXT ARE THE CARD'S, NEVER THE MODEL'S (总线程's
|
|
7
|
+
* review of 0.63.0, binding): a group's terms are text a stranger wrote, and a
|
|
8
|
+
* model that reads them can be talked into acting on them (prompt injection).
|
|
9
|
+
* The model gets facts and the sentence `termsSaid`; the card gets this, in
|
|
10
|
+
* `_meta` - and only a client that said it draws cards (`ToolContext.drawsCards`):
|
|
11
|
+
* some hosts hand `_meta` to their model.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TERMS_META_KEY = "curless/terms";
|
|
14
|
+
/**
|
|
15
|
+
* The photographs of each room type the card's gallery opens, beside the answer (`_meta`):
|
|
16
|
+
* `{ [hotelId]: { [roomTypeId]: string[] } }`, the cover first, once a type (never once a
|
|
17
|
+
* rate) and only for a type with more than one. ⚠️ NEVER IN WHAT THE MODEL READS (robin
|
|
18
|
+
* 11-19, 总线程): a Huazhu hotel has up to 84 room photographs, the model needs no address of
|
|
19
|
+
* them - and only to a client that said it draws cards, as some hosts hand `_meta` to their
|
|
20
|
+
* model. The card puts a list back as the room's `images` (card.ts `withKept`).
|
|
21
|
+
*/
|
|
22
|
+
export declare const ROOM_PHOTOS_META_KEY = "curless/room-photos";
|
|
23
|
+
/**
|
|
24
|
+
* The hotel's own photographs for the page's strip (0.77.1), beside the answer (`_meta`):
|
|
25
|
+
* `{ [hotelId]: { photos: string[], kinds: string[] } }` - the lead photograph (the one the
|
|
26
|
+
* page shows above the name) first, then cover, outside, facilities, surroundings, meeting
|
|
27
|
+
* rooms; `kinds[i]` is what `photos[i]` shows (`HotelPhotoKind`), for the card to name under
|
|
28
|
+
* it. At most 30, always two or more. ⚠️ NEVER IN WHAT THE MODEL READS, and only to a client
|
|
29
|
+
* that said it draws cards (as `ROOM_PHOTOS_META_KEY`).
|
|
30
|
+
*/
|
|
31
|
+
export declare const HOTEL_PHOTOS_META_KEY = "curless/hotel-photos";
|
|
32
|
+
/**
|
|
33
|
+
* Where the hotel is, for the card's 「在地图中打开」 (0.77.1): `{ [hotelId]: { lat, lng } }`, the
|
|
34
|
+
* supplier's own coordinates (Huazhu: China's GCJ-02). The card makes the map link itself. Beside
|
|
35
|
+
* the answer, card clients only, never in what the model reads.
|
|
36
|
+
*/
|
|
37
|
+
export declare const HOTEL_GEO_META_KEY = "curless/hotel-geo";
|
|
38
|
+
/** What the hotel page tells the model of the hotel itself - the same fields, as words (`HotelFacts`). */
|
|
39
|
+
export declare const hotelFactsText: (f: HotelFacts | undefined) => string;
|
|
40
|
+
/** The longest stretch of a group's refund terms put in the answer. */
|
|
41
|
+
export declare const TERMS_TEXT_MAX = 2000;
|
|
42
|
+
/**
|
|
43
|
+
* Terms a group sent back, for the GUEST to agree to - as the structure and as
|
|
44
|
+
* words, in the two kinds of host.
|
|
45
|
+
*
|
|
46
|
+
* ⚠️ THE MODEL CANNOT AGREE FOR THE GUEST, and no tool parameter means "agreed":
|
|
47
|
+
* the card's button (`acceptTerms`, the card's own tool) or the one-time page
|
|
48
|
+
* is the only way, and the words say so first. The text and the structure say
|
|
49
|
+
* the same (`termsSaid`) - the model reads the structure. Neither carries the
|
|
50
|
+
* terms' `ref` or their text: see `TERMS_META_KEY`.
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* Whether a link to our pages is handed out with the words of a Lax account cookie (0.84.0): a client
|
|
54
|
+
* that said it draws no card, on a deployment with `account.cookieSameSite: "Lax"` - see
|
|
55
|
+
* `ToolDeps.accountCookieLax`. A card host's words, and every word of the root deployment, as before.
|
|
56
|
+
*/
|
|
57
|
+
export declare const inBrowserWords: (deps: ToolDeps, ctx: ToolContext) => boolean;
|
|
58
|
+
export declare const termsAnswer: (deps: ToolDeps, ctx: ToolContext, key: string, terms: TermsToAgree[]) => {
|
|
59
|
+
structured: Record<string, unknown>;
|
|
60
|
+
text: string;
|
|
61
|
+
meta?: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* ⚠️ THE BOOKINGS, THE LATEST ORDERED FIRST (0.84.5, `data.bookingsByTime`; robin 11-26: 「我的预订没有排序,应该最近订的在最上面」;
|
|
65
|
+
* 0.84.4 had them in parts by state, which he did not see as an order): the card's own order, in words - ONE list,
|
|
66
|
+
* the booking made last on top, each line headed with when it was made (UTC, to the minute) and carrying its state
|
|
67
|
+
* and hotel (and its Chinese name) as ever, with one line of how many are in each state. A guest asking for one
|
|
68
|
+
* hotel's booking is answered from these lines. A booking whose time is not known or not to be trusted (none, not a
|
|
69
|
+
* date, before 2020, more than a day ahead of now) is listed after the others, the later check-in first, and says
|
|
70
|
+
* "booking time not known" - never a time we made up. "Stayed" is a check-out before today in UTC - a day out at
|
|
71
|
+
* most at either end of the world.
|
|
72
|
+
*/
|
|
73
|
+
export declare const bookingsInTime: (list: Booking[], line: (b: Booking) => string, now: number) => string;
|
|
74
|
+
export declare const bookingLine: (deps: ToolDeps, b: Booking, noCards?: boolean) => string;
|
|
75
|
+
/**
|
|
76
|
+
* The window of nearby arrival dates, plus the one sentence worth saying about
|
|
77
|
+
* it in prose.
|
|
78
|
+
*
|
|
79
|
+
* ⚠️ THE SENTENCE IS SAID ONCE, OR NOT AT ALL. The window's prices belong to the
|
|
80
|
+
* card - the date picker puts each under its day (the hotel page's own strip of
|
|
81
|
+
* them was taken away, robin 2026-10-22); repeating them in text costs the
|
|
82
|
+
* model's context and tells it nothing it can act on. What prose is good
|
|
83
|
+
* for is the single fact a picture hides: that a date the guest did not ask
|
|
84
|
+
* about is cheaper, or - when the asked-for nights are gone - that a date
|
|
85
|
+
* nearby is free at all.
|
|
86
|
+
*
|
|
87
|
+
* ⚠️ AND IT NAMES THE DATE. "The one before" or "the third day" is meaningless
|
|
88
|
+
* the moment the card reflows or the guest is reading on a phone; a date is the
|
|
89
|
+
* same fact wherever it is read.
|
|
90
|
+
*/
|
|
91
|
+
export declare const dateFlex: (dates: DateOption[], stay: Stay) => {
|
|
92
|
+
structured: Record<string, unknown>;
|
|
93
|
+
text: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The room types a guest can no longer book on these nights - for the card to
|
|
97
|
+
* say so, and not leave them out (r10 #10: a type the guest saw earlier
|
|
98
|
+
* vanished from the list, and the heading counted one fewer, without a word).
|
|
99
|
+
*
|
|
100
|
+
* ⚠️ AN ADDITIVE FIELD, NEVER THE TEXT. What the assistant is told is the rooms
|
|
101
|
+
* that can be booked, as before; this is only what the card draws, muted, at
|
|
102
|
+
* the end of the list. A type is listed when
|
|
103
|
+
* - the backend sends it with none left (`HotelDetail.soldOut`, or a room with
|
|
104
|
+
* `roomsLeft: 0`), or
|
|
105
|
+
* - it has some left, but fewer than the rooms asked for (`left`): a guest who
|
|
106
|
+
* asked for two rooms and was shown no type with one left was not told why.
|
|
107
|
+
* Not a type that sleeps fewer than the party (the backend never sends it), and
|
|
108
|
+
* not a type any of whose rates can be booked. One entry a type, with the facts
|
|
109
|
+
* the card says of a room and no price.
|
|
110
|
+
*/
|
|
111
|
+
export declare const soldOutTypesOf: (detail: HotelDetail, enough: Room[], wanted: number) => Record<string, unknown>[];
|
|
112
|
+
/** A code that opens no booking here: where orders are the account's, no email would have opened it. */
|
|
113
|
+
export declare const noBookingLike: (deps: ToolDeps) => string;
|
|
114
|
+
//# sourceMappingURL=terms-answer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terms-answer.d.ts","sourceRoot":"","sources":["../../src/tools/terms-answer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAmBvD;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,wBAAwB,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,yBAAyB,CAAC;AAC5D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AAEtD,0GAA0G;AAC1G,eAAO,MAAM,cAAc,GAAI,GAAG,UAAU,GAAG,SAAS,KAAG,MAS1D,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,cAAc,OAAQ,CAAC;AAEpC;;;;;;;;;GASG;AACH;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,QAAQ,EAAE,KAAK,WAAW,KAAG,OACV,CAAC;AAEzD,eAAO,MAAM,WAAW,GACtB,MAAM,QAAQ,EACd,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,OAAO,YAAY,EAAE,KACpB;IAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAWrF,CAAC;AAwLF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,OAAO,EAAE,EACf,MAAM,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,EAC5B,KAAK,MAAM,KACV,MA6CF,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,MAAM,QAAQ,EAAE,GAAG,OAAO,EAAE,UAAU,OAAO,KAAG,MA+C3E,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GACnB,OAAO,UAAU,EAAE,EACnB,MAAM,IAAI,KACT;IAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAiErD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,WAAW,EACnB,QAAQ,IAAI,EAAE,EACd,QAAQ,MAAM,KACb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EA4BzB,CAAC;AAEF,wGAAwG;AACxG,eAAO,MAAM,aAAa,GAAI,MAAM,QAAQ,KAAG,MAGoE,CAAC"}
|
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
import { GUEST_ALONE, OPENS_SIGNED_IN } from '../account/page-words.js';
|
|
2
|
+
import { FULL_CAPABILITIES } from '../backend.js';
|
|
3
|
+
import { nights as nightsBetween } from '../dates.js';
|
|
4
|
+
import { stayWords } from '../hourly.js';
|
|
5
|
+
import { formatMoney, money } from '../money.js';
|
|
6
|
+
import { holderOf } from './cancel-facts.js';
|
|
7
|
+
import { differsSaid, shownPriceSaid } from './paid-lines.js';
|
|
8
|
+
import { LINK_CLOSED_WORDS, bookingNotes, clockWords, heldRoomsWords, hostOf, notSentStatus, payByWords, paymentWords, termsHeldWords, unconfirmedSaid, } from './payment-words.js';
|
|
9
|
+
import { couponName, withZh } from './quote-card.js';
|
|
10
|
+
import { bare } from './request-words.js';
|
|
11
|
+
import { listAnd } from './session-notes.js';
|
|
12
|
+
import { ordersByAccount } from './tool-set.js';
|
|
13
|
+
/**
|
|
14
|
+
* The card's copy of the terms to agree to, beside the answer (`_meta`).
|
|
15
|
+
*
|
|
16
|
+
* ⚠️ THE TERMS' REF AND FULL TEXT ARE THE CARD'S, NEVER THE MODEL'S (总线程's
|
|
17
|
+
* review of 0.63.0, binding): a group's terms are text a stranger wrote, and a
|
|
18
|
+
* model that reads them can be talked into acting on them (prompt injection).
|
|
19
|
+
* The model gets facts and the sentence `termsSaid`; the card gets this, in
|
|
20
|
+
* `_meta` - and only a client that said it draws cards (`ToolContext.drawsCards`):
|
|
21
|
+
* some hosts hand `_meta` to their model.
|
|
22
|
+
*/
|
|
23
|
+
export const TERMS_META_KEY = 'curless/terms';
|
|
24
|
+
/**
|
|
25
|
+
* The photographs of each room type the card's gallery opens, beside the answer (`_meta`):
|
|
26
|
+
* `{ [hotelId]: { [roomTypeId]: string[] } }`, the cover first, once a type (never once a
|
|
27
|
+
* rate) and only for a type with more than one. ⚠️ NEVER IN WHAT THE MODEL READS (robin
|
|
28
|
+
* 11-19, 总线程): a Huazhu hotel has up to 84 room photographs, the model needs no address of
|
|
29
|
+
* them - and only to a client that said it draws cards, as some hosts hand `_meta` to their
|
|
30
|
+
* model. The card puts a list back as the room's `images` (card.ts `withKept`).
|
|
31
|
+
*/
|
|
32
|
+
export const ROOM_PHOTOS_META_KEY = 'curless/room-photos';
|
|
33
|
+
/**
|
|
34
|
+
* The hotel's own photographs for the page's strip (0.77.1), beside the answer (`_meta`):
|
|
35
|
+
* `{ [hotelId]: { photos: string[], kinds: string[] } }` - the lead photograph (the one the
|
|
36
|
+
* page shows above the name) first, then cover, outside, facilities, surroundings, meeting
|
|
37
|
+
* rooms; `kinds[i]` is what `photos[i]` shows (`HotelPhotoKind`), for the card to name under
|
|
38
|
+
* it. At most 30, always two or more. ⚠️ NEVER IN WHAT THE MODEL READS, and only to a client
|
|
39
|
+
* that said it draws cards (as `ROOM_PHOTOS_META_KEY`).
|
|
40
|
+
*/
|
|
41
|
+
export const HOTEL_PHOTOS_META_KEY = 'curless/hotel-photos';
|
|
42
|
+
/**
|
|
43
|
+
* Where the hotel is, for the card's 「在地图中打开」 (0.77.1): `{ [hotelId]: { lat, lng } }`, the
|
|
44
|
+
* supplier's own coordinates (Huazhu: China's GCJ-02). The card makes the map link itself. Beside
|
|
45
|
+
* the answer, card clients only, never in what the model reads.
|
|
46
|
+
*/
|
|
47
|
+
export const HOTEL_GEO_META_KEY = 'curless/hotel-geo';
|
|
48
|
+
/** What the hotel page tells the model of the hotel itself - the same fields, as words (`HotelFacts`). */
|
|
49
|
+
export const hotelFactsText = (f) => {
|
|
50
|
+
if (!f)
|
|
51
|
+
return '';
|
|
52
|
+
const parts = [
|
|
53
|
+
f.phone ? `phone ${f.phone.zh} (from abroad ${f.phone.en})` : '',
|
|
54
|
+
f.openedYear ? `opened ${f.openedYear}` : '',
|
|
55
|
+
f.renovatedYear ? `renovated ${f.renovatedYear}` : '',
|
|
56
|
+
f.roomCount ? `${f.roomCount} rooms in all` : '',
|
|
57
|
+
].filter(Boolean);
|
|
58
|
+
return parts.length ? `About the hotel: ${parts.join(', ')}.` : '';
|
|
59
|
+
};
|
|
60
|
+
/** The longest stretch of a group's refund terms put in the answer. */
|
|
61
|
+
export const TERMS_TEXT_MAX = 2_000;
|
|
62
|
+
/**
|
|
63
|
+
* Terms a group sent back, for the GUEST to agree to - as the structure and as
|
|
64
|
+
* words, in the two kinds of host.
|
|
65
|
+
*
|
|
66
|
+
* ⚠️ THE MODEL CANNOT AGREE FOR THE GUEST, and no tool parameter means "agreed":
|
|
67
|
+
* the card's button (`acceptTerms`, the card's own tool) or the one-time page
|
|
68
|
+
* is the only way, and the words say so first. The text and the structure say
|
|
69
|
+
* the same (`termsSaid`) - the model reads the structure. Neither carries the
|
|
70
|
+
* terms' `ref` or their text: see `TERMS_META_KEY`.
|
|
71
|
+
*/
|
|
72
|
+
/**
|
|
73
|
+
* Whether a link to our pages is handed out with the words of a Lax account cookie (0.84.0): a client
|
|
74
|
+
* that said it draws no card, on a deployment with `account.cookieSameSite: "Lax"` - see
|
|
75
|
+
* `ToolDeps.accountCookieLax`. A card host's words, and every word of the root deployment, as before.
|
|
76
|
+
*/
|
|
77
|
+
export const inBrowserWords = (deps, ctx) => deps.accountCookieLax === true && ctx.noCards === true;
|
|
78
|
+
export const termsAnswer = (deps, ctx, key, terms) => {
|
|
79
|
+
// A client that draws no card, or that never said it does, is given the page.
|
|
80
|
+
const onPage = !!ctx.noCards || !ctx.drawsCards;
|
|
81
|
+
const termsSaid = termsSaidOf(deps, ctx, terms, onPage);
|
|
82
|
+
const entries = termEntries(deps, key, terms, onPage);
|
|
83
|
+
const blocks = termBlocks(deps, ctx, entries, onPage);
|
|
84
|
+
return {
|
|
85
|
+
structured: { terms: entries.map((e) => e.entry), termsSaid },
|
|
86
|
+
text: [termsSaid, ...blocks].filter(Boolean).join('\n\n'),
|
|
87
|
+
...termsMetaOf(ctx, terms),
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/** What is said once of the terms waiting for the guest: whose they are, who agrees and where. */
|
|
91
|
+
const termsSaidOf = (deps, ctx, terms, onPage) => {
|
|
92
|
+
const groupOf = (x) => withZh(x.groupName, x.groupNames, ctx.noCards);
|
|
93
|
+
const namesOf = (xs) => [...new Set(xs.map(groupOf))];
|
|
94
|
+
// Terms the group asked for when the booking was sent (`askedByGroup`, 0.67.0, questions
|
|
95
|
+
// #66): nothing is ordered, and the booking is sent once more when the guest has agreed.
|
|
96
|
+
const asked = terms.filter((x) => x.askedByGroup === 'terms' && !x.changed);
|
|
97
|
+
// …or to confirm the booking itself (`askedByGroup: 'confirm'`, questions #68).
|
|
98
|
+
// 0.67.1: with the order's `bookingId` the order EXISTS and its payment page is held -
|
|
99
|
+
// never "nothing has been ordered" of those.
|
|
100
|
+
const confirmOrder = terms.filter((x) => x.askedByGroup === 'confirm' && !x.changed && !!x.bookingId);
|
|
101
|
+
const confirm = terms.filter((x) => x.askedByGroup === 'confirm' && !x.changed && !x.bookingId);
|
|
102
|
+
const before = terms.filter((x) => !x.changed && !x.askedByGroup);
|
|
103
|
+
const changed = terms.filter((x) => x.changed);
|
|
104
|
+
const where = onPage
|
|
105
|
+
? inBrowserWords(deps, ctx)
|
|
106
|
+
? 'on the one-time page linked below, in their own browser, signed in to their account there'
|
|
107
|
+
: "on the one-time page linked below, which opens only in the browser signed in to the guest's account"
|
|
108
|
+
: `on the card, with its ${terms.every((x) => x.askedByGroup === 'confirm') ? 'Confirm' : 'Agree'} button`;
|
|
109
|
+
// ⚠️ EVERY BOOKING STARTS WITH ITS TERMS (Otaless 0.66.0, 8 booking/create, docs/
|
|
110
|
+
// otaless-hotels.md §15): nothing is ordered before the guest agrees - but terms the
|
|
111
|
+
// group answered an ORDER with (`changed`, 总线程 11-11, D) come after it was made:
|
|
112
|
+
// never "nothing is ordered" of those, and never "cancelling is free before paying".
|
|
113
|
+
const confirmCodes = confirmOrder.map((x) => x.confirmationCode ?? x.bookingId).filter(Boolean);
|
|
114
|
+
const codes = changed.map((x) => x.confirmationCode ?? x.bookingId).filter(Boolean);
|
|
115
|
+
// ⚠️ "THE GROUP MAY HAVE TERMS OF ITS OWN" IS NOT SAID OF THESE (0.67.0): the group has
|
|
116
|
+
// just asked for its own, and they are the ones below - the sentence would contradict it.
|
|
117
|
+
const all = namesOf(terms.filter((x) => !x.askedByGroup));
|
|
118
|
+
const termsSaid = [
|
|
119
|
+
before.length
|
|
120
|
+
? // The facts, not a line to read out (robin 11-16 through 总线程, 0.72.3).
|
|
121
|
+
`Not booked yet, nothing ordered: the guest agrees to its cancellation terms themselves, ${where} - then it is booked.`
|
|
122
|
+
: '',
|
|
123
|
+
confirmOrder.length
|
|
124
|
+
? `Not paid yet, and no payment page: ${listAnd(namesOf(confirmOrder))} made the order${confirmCodes.length ? ` (${confirmCodes.join(', ')})` : ''} and asks the guest to confirm what is below first. The guest confirms it themselves, ${where}; once they have, the payment page is given; if they have not confirmed by the time below, the order is cancelled.`
|
|
125
|
+
: '',
|
|
126
|
+
confirm.length
|
|
127
|
+
? `Not booked yet: ${listAnd(namesOf(confirm))} asked, when the booking was sent, for the guest to confirm it first - what it asks to confirm is below; nothing has been ordered. The guest confirms it themselves, ${where}; once they have, the booking is sent again.`
|
|
128
|
+
: '',
|
|
129
|
+
// ⚠️ THE FACTS, NOT THE STORY (robin 11-16 through 总线程): "<group> asked, when the
|
|
130
|
+
// booking was sent, for…" was read out to the guest as it stood - the card no longer says
|
|
131
|
+
// it either. Not booked, nothing ordered, whose terms, who agrees and where, what then.
|
|
132
|
+
asked.length
|
|
133
|
+
? `Not booked yet, nothing ordered: ${asked.length > 1 ? `${listAnd(namesOf(asked))} each have` : `${listAnd(namesOf(asked))} has`} terms of ${asked.length > 1 ? 'their' : 'its'} own, which the guest agrees to themselves, ${where} - then it is booked.`
|
|
134
|
+
: '',
|
|
135
|
+
changed.length
|
|
136
|
+
? `Not paid yet, and no payment page: ${listAnd(namesOf(changed))} answered the order${codes.length ? ` (${codes.join(', ')})` : ''} with cancellation terms that are not the ones the guest saw before. The guest reads the new terms and decides, ${where}: if they agree, the payment page is given; if they have not agreed by the time below, the order is cancelled.`
|
|
137
|
+
: '',
|
|
138
|
+
// ⚠️ ALWAYS, UNTIL QUESTIONS #61 (3) IS ANSWERED (总线程 11-11, A).
|
|
139
|
+
all.length
|
|
140
|
+
? `${listAnd(all)} may also have terms of ${all.length > 1 ? 'their' : 'its'} own when the booking is made, which are not shown here.`
|
|
141
|
+
: '',
|
|
142
|
+
'You cannot agree for them, and do not ask them to say they agree in the chat.',
|
|
143
|
+
]
|
|
144
|
+
.filter(Boolean)
|
|
145
|
+
.join(' ');
|
|
146
|
+
return termsSaid;
|
|
147
|
+
};
|
|
148
|
+
/** Each terms to agree to, as the card holds it, with the page to agree on where there is one. */
|
|
149
|
+
const termEntries = (deps, key, terms, onPage) => {
|
|
150
|
+
return terms.map((x) => {
|
|
151
|
+
const link = onPage ? deps.termsLink?.(key, x.ref) : undefined;
|
|
152
|
+
return {
|
|
153
|
+
entry: {
|
|
154
|
+
group: x.group,
|
|
155
|
+
groupName: x.groupName,
|
|
156
|
+
...(x.groupNames ? { groupNames: x.groupNames } : {}),
|
|
157
|
+
hotelId: x.hotelId,
|
|
158
|
+
hotelName: x.hotelName,
|
|
159
|
+
...(x.hotelNames ? { hotelNames: x.hotelNames } : {}),
|
|
160
|
+
roomName: x.roomName,
|
|
161
|
+
stay: x.stay,
|
|
162
|
+
rooms: x.rooms,
|
|
163
|
+
total: formatMoney(x.total),
|
|
164
|
+
totalMoney: x.total,
|
|
165
|
+
// What the payment may be taken in, as the backend gave it (0.84.2, P1-4).
|
|
166
|
+
...(x.payAs ? { payAs: formatMoney(x.payAs) } : {}),
|
|
167
|
+
// ⚠️ THE MOMENT ONLY (0.63.0 screenshots): the card writes it in the viewer's own
|
|
168
|
+
// language and time zone. "10:05 UTC, 10 Nov" here was drawn as is in a
|
|
169
|
+
// Chinese card - and it is not the hotel's clock anyway (no zone is sent).
|
|
170
|
+
until: x.until,
|
|
171
|
+
// Where the terms are from, and what is said beside them (0.66.0): none for the
|
|
172
|
+
// room said in our words, the group's own at booking always, an order's changed.
|
|
173
|
+
source: x.source ?? 'room',
|
|
174
|
+
// Not of terms the group has just asked for (0.67.0): they are its own terms.
|
|
175
|
+
...(x.askedByGroup ? { askedByGroup: x.askedByGroup } : { more: true }),
|
|
176
|
+
...(x.changed ? { changed: true } : {}),
|
|
177
|
+
...((x.changed || (x.askedByGroup === 'confirm' && x.bookingId)) &&
|
|
178
|
+
(x.confirmationCode ?? x.bookingId)
|
|
179
|
+
? { confirmationCode: x.confirmationCode ?? x.bookingId }
|
|
180
|
+
: {}),
|
|
181
|
+
...(link ? { link } : {}),
|
|
182
|
+
},
|
|
183
|
+
link,
|
|
184
|
+
x,
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
/** Each terms to agree to, as words. */
|
|
189
|
+
const termBlocks = (deps, ctx, entries, onPage) => {
|
|
190
|
+
const t = deps.tools;
|
|
191
|
+
return entries.map(({ link, x }) => {
|
|
192
|
+
const until = clockWords(x.until) ?? x.until;
|
|
193
|
+
const heldOrder = x.askedByGroup === 'confirm' && !x.changed && !!x.bookingId;
|
|
194
|
+
const code = x.changed || heldOrder ? (x.confirmationCode ?? x.bookingId) : undefined;
|
|
195
|
+
return [
|
|
196
|
+
`${withZh(x.hotelName, x.hotelNames, ctx.noCards)} · ${x.roomName} · ${stayWords(x.stay)} · ${x.rooms} ${x.rooms === 1 ? 'room' : 'rooms'} · ${formatMoney(x.total)} · ${x.groupName}${code ? ` · order ${code}` : ''}`,
|
|
197
|
+
x.source === 'none' ? `${x.groupName} gave no cancellation terms for this room.` : '',
|
|
198
|
+
// ⚠️ SAID BEFORE THE GUEST AGREES (0.84.2, the 11-25 code audit's P1-4; 总线程 11-25): the
|
|
199
|
+
// group's page may ask its own USD figure for this price - as the backend gave it.
|
|
200
|
+
x.payAs
|
|
201
|
+
? `${x.groupName}'s payment page may ask ${formatMoney(x.payAs)} for it - ${x.groupName}'s own figure in ${x.payAs.currency} for this price, not converted here; tell the guest before they agree.`
|
|
202
|
+
: '',
|
|
203
|
+
x.changed
|
|
204
|
+
? `They can be agreed to until ${until}; not agreed by then, the order is cancelled.`
|
|
205
|
+
: heldOrder
|
|
206
|
+
? `It can be confirmed until ${until}; not confirmed by then, the order is cancelled.`
|
|
207
|
+
: x.askedByGroup === 'confirm'
|
|
208
|
+
? `It can be confirmed until ${until}.`
|
|
209
|
+
: `They can be agreed to until ${until}.`,
|
|
210
|
+
onPage
|
|
211
|
+
? link
|
|
212
|
+
? inBrowserWords(deps, ctx)
|
|
213
|
+
? `Give the guest this one-time link to read the terms and agree on ${deps.vocab.brand}'s page - it works once, until ${clockWords(link.expiresAt) ?? link.expiresAt}: ${link.url}. ${OPENS_SIGNED_IN} ${GUEST_ALONE} When they say they are done, call ${t.listBookings} to see the booking and its payment page.`
|
|
214
|
+
: `Give the guest this one-time link to read the terms and agree on ${deps.vocab.brand}'s page - it opens only in the browser signed in to their ${deps.vocab.brand} account, works once, until ${clockWords(link.expiresAt) ?? link.expiresAt}: ${link.url}. When they say they are done, call ${t.listBookings} to see the booking and its payment page.`
|
|
215
|
+
: x.changed
|
|
216
|
+
? 'These terms can only be agreed to on a client that shows the card.'
|
|
217
|
+
: heldOrder
|
|
218
|
+
? 'This can only be confirmed on a client that shows the card.'
|
|
219
|
+
: x.askedByGroup === 'confirm'
|
|
220
|
+
? 'This can only be confirmed on a client that shows the card; nothing was ordered.'
|
|
221
|
+
: 'These terms can only be agreed to on a client that shows the card; nothing was ordered.'
|
|
222
|
+
: '',
|
|
223
|
+
]
|
|
224
|
+
.filter(Boolean)
|
|
225
|
+
.join('\n');
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
/** The terms' own text, for the card alone (`TERMS_META_KEY`). */
|
|
229
|
+
const termsMetaOf = (ctx, terms) => {
|
|
230
|
+
return (ctx.drawsCards && !ctx.noCards) || ctx.termsMeta
|
|
231
|
+
? {
|
|
232
|
+
meta: {
|
|
233
|
+
[TERMS_META_KEY]: {
|
|
234
|
+
terms: terms.map((x) => ({
|
|
235
|
+
ref: x.ref,
|
|
236
|
+
group: x.group,
|
|
237
|
+
groupName: x.groupName,
|
|
238
|
+
...(x.groupNames ? { groupNames: x.groupNames } : {}),
|
|
239
|
+
hotelId: x.hotelId,
|
|
240
|
+
hotelName: x.hotelName,
|
|
241
|
+
...(x.hotelNames ? { hotelNames: x.hotelNames } : {}),
|
|
242
|
+
roomName: x.roomName,
|
|
243
|
+
stay: x.stay,
|
|
244
|
+
rooms: x.rooms,
|
|
245
|
+
total: formatMoney(x.total),
|
|
246
|
+
totalMoney: x.total,
|
|
247
|
+
...(x.payAs ? { payAs: formatMoney(x.payAs) } : {}),
|
|
248
|
+
text: x.text,
|
|
249
|
+
until: x.until,
|
|
250
|
+
})),
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
}
|
|
254
|
+
: {};
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* ⚠️ THE BOOKINGS, THE LATEST ORDERED FIRST (0.84.5, `data.bookingsByTime`; robin 11-26: 「我的预订没有排序,应该最近订的在最上面」;
|
|
258
|
+
* 0.84.4 had them in parts by state, which he did not see as an order): the card's own order, in words - ONE list,
|
|
259
|
+
* the booking made last on top, each line headed with when it was made (UTC, to the minute) and carrying its state
|
|
260
|
+
* and hotel (and its Chinese name) as ever, with one line of how many are in each state. A guest asking for one
|
|
261
|
+
* hotel's booking is answered from these lines. A booking whose time is not known or not to be trusted (none, not a
|
|
262
|
+
* date, before 2020, more than a day ahead of now) is listed after the others, the later check-in first, and says
|
|
263
|
+
* "booking time not known" - never a time we made up. "Stayed" is a check-out before today in UTC - a day out at
|
|
264
|
+
* most at either end of the world.
|
|
265
|
+
*/
|
|
266
|
+
export const bookingsInTime = (list, line, now) => {
|
|
267
|
+
const today = new Date(now).toISOString().slice(0, 10);
|
|
268
|
+
const kind = (b) => b.status === 'cancelled' || b.status === 'expired' || b.status === 'failed'
|
|
269
|
+
? 'off'
|
|
270
|
+
: b.stay?.checkOut && b.stay.checkOut < today
|
|
271
|
+
? 'past'
|
|
272
|
+
: b.status === 'awaiting-payment'
|
|
273
|
+
? 'pay'
|
|
274
|
+
: 'up';
|
|
275
|
+
const madeAt = (b) => {
|
|
276
|
+
const t = typeof b.createdAt === 'string' ? Date.parse(b.createdAt) : Number.NaN;
|
|
277
|
+
return Number.isFinite(t) && t >= Date.UTC(2020, 0, 1) && t <= now + 86_400_000
|
|
278
|
+
? t
|
|
279
|
+
: Number.NaN;
|
|
280
|
+
};
|
|
281
|
+
const ci = (b) => String(b.stay?.checkIn ?? '');
|
|
282
|
+
const sorted = [...list].sort((a, b) => {
|
|
283
|
+
const ta = madeAt(a);
|
|
284
|
+
const tb = madeAt(b);
|
|
285
|
+
if (Number.isNaN(ta) !== Number.isNaN(tb))
|
|
286
|
+
return Number.isNaN(ta) ? 1 : -1;
|
|
287
|
+
if (!Number.isNaN(ta) && ta !== tb)
|
|
288
|
+
return tb - ta;
|
|
289
|
+
return Number.isNaN(ta) ? ci(b).localeCompare(ci(a)) : 0;
|
|
290
|
+
});
|
|
291
|
+
const words = {
|
|
292
|
+
pay: 'to pay',
|
|
293
|
+
up: 'upcoming',
|
|
294
|
+
past: 'stayed',
|
|
295
|
+
off: 'cancelled, expired or not made',
|
|
296
|
+
};
|
|
297
|
+
const counts = ['pay', 'up', 'past', 'off']
|
|
298
|
+
.map((k) => [k, list.filter((b) => kind(b) === k).length])
|
|
299
|
+
.filter(([, n]) => n > 0)
|
|
300
|
+
.map(([k, n]) => `${n} ${words[k]}`)
|
|
301
|
+
.join(', ');
|
|
302
|
+
const when = (b) => {
|
|
303
|
+
const t = madeAt(b);
|
|
304
|
+
return Number.isNaN(t)
|
|
305
|
+
? 'booking time not known'
|
|
306
|
+
: `booked ${new Date(t).toISOString().slice(0, 16).replace('T', ' ')} UTC`;
|
|
307
|
+
};
|
|
308
|
+
return [
|
|
309
|
+
`Bookings, latest booked first (${list.length}: ${counts}):`,
|
|
310
|
+
...sorted.map((b) => `[${when(b)}] ${line(b)}`),
|
|
311
|
+
].join('\n');
|
|
312
|
+
};
|
|
313
|
+
export const bookingLine = (deps, b, noCards) => {
|
|
314
|
+
const kinds = b.requests?.kinds ?? [];
|
|
315
|
+
const held = noCards ? heldRoomsWords(b) : '';
|
|
316
|
+
const notSent = holderOf(deps, b.supplier).notReal;
|
|
317
|
+
return [
|
|
318
|
+
`${b.confirmationCode}${b.orderNumber ? ` (order number ${b.orderNumber})` : ''} · ${withZh(b.hotelName, b.hotelNames, noCards)} · ${stayWords(b.stay, b.hourly)} · ${notSentStatus(deps, b) ??
|
|
319
|
+
unconfirmedSaid(deps, b) ??
|
|
320
|
+
// ⚠️ SAID AS WHAT IT IS - see BookingStatus. Neither booked nor failed.
|
|
321
|
+
(b.status === 'unconfirmed'
|
|
322
|
+
? 'unconfirmed: whether it was made is not known yet, and a person is confirming it'
|
|
323
|
+
: b.status)}`,
|
|
324
|
+
held ? ` · ${held}` : '',
|
|
325
|
+
kinds.length ? ` · asked for ${kinds.map(bare).join(', ')}` : '',
|
|
326
|
+
b.quote.coupon
|
|
327
|
+
? ` · coupon ${couponName(b.quote.coupon)} −${formatMoney(b.quote.coupon.off)}${b.couponReturned === true
|
|
328
|
+
? ' (given back)'
|
|
329
|
+
: b.couponReturned === false
|
|
330
|
+
? b.couponNotReturnedBecause === 'fee'
|
|
331
|
+
? notSent
|
|
332
|
+
? ' (not given back - under the terms the cancellation costs a fee)'
|
|
333
|
+
: ' (not given back - the cancellation was charged a fee)'
|
|
334
|
+
: ' (ran out - not given back)'
|
|
335
|
+
: ''}`
|
|
336
|
+
: '',
|
|
337
|
+
b.payment
|
|
338
|
+
? // ⚠️ THE PAGE BY ITS HOST, NOT "THE CARD PAGE" (0.63.0 transcript): beside a
|
|
339
|
+
// host the old words read "to be paid on the card page - pay on <host>", and a
|
|
340
|
+
// client with no card reads "card page" as the booking card's.
|
|
341
|
+
b.payment.status === 'awaiting' && b.payment.url
|
|
342
|
+
? ` · to be paid on ${hostOf(b.payment.url) ?? 'its payment page'}${payByWords(b.payment) ? ` by ${payByWords(b.payment)}` : ''}: ${b.payment.url}`
|
|
343
|
+
: b.payment.status === 'awaiting' &&
|
|
344
|
+
b.payment.method === 'card' &&
|
|
345
|
+
deps.backend.otalessBooking
|
|
346
|
+
? ` · ${b.termsChanged || b.confirmAsked ? termsHeldWords(deps, b) : LINK_CLOSED_WORDS}`
|
|
347
|
+
: ` · ${paymentWords(b)}${shownPriceSaid(b.payment, holderOf(deps, b.supplier).name, b.status === 'cancelled' || b.status === 'expired' || b.status === 'failed').replace(/^ /, ' - ')}`
|
|
348
|
+
: // ⚠️ CONFIRMED WITH NO PAGE, ITS PAYMENT NOT KNOWN (Otaless 0.84.2, P0-1).
|
|
349
|
+
b.paymentUnknown
|
|
350
|
+
? ` · ${b.status === 'cancelled' ? 'cancelled - whether it had been charged is still not known; a person here follows it up' : 'whether it has been charged (to a wallet or card at the group) is being checked - nothing to pay here now'}`
|
|
351
|
+
: '',
|
|
352
|
+
bookingNotes(deps, b) ? ` · ${bookingNotes(deps, b)}` : '',
|
|
353
|
+
// 0.84.2 (总线程's re-review): what is not as chosen.
|
|
354
|
+
differsSaid(deps, b) ? ` · ${differsSaid(deps, b)}` : '',
|
|
355
|
+
].join('');
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* The window of nearby arrival dates, plus the one sentence worth saying about
|
|
359
|
+
* it in prose.
|
|
360
|
+
*
|
|
361
|
+
* ⚠️ THE SENTENCE IS SAID ONCE, OR NOT AT ALL. The window's prices belong to the
|
|
362
|
+
* card - the date picker puts each under its day (the hotel page's own strip of
|
|
363
|
+
* them was taken away, robin 2026-10-22); repeating them in text costs the
|
|
364
|
+
* model's context and tells it nothing it can act on. What prose is good
|
|
365
|
+
* for is the single fact a picture hides: that a date the guest did not ask
|
|
366
|
+
* about is cheaper, or - when the asked-for nights are gone - that a date
|
|
367
|
+
* nearby is free at all.
|
|
368
|
+
*
|
|
369
|
+
* ⚠️ AND IT NAMES THE DATE. "The one before" or "the third day" is meaningless
|
|
370
|
+
* the moment the card reflows or the guest is reading on a phone; a date is the
|
|
371
|
+
* same fact wherever it is read.
|
|
372
|
+
*/
|
|
373
|
+
export const dateFlex = (dates, stay) => {
|
|
374
|
+
const chosen = dates.find((d) => d.chosen);
|
|
375
|
+
const others = dates.filter((d) => !d.chosen && d.from);
|
|
376
|
+
// One date is not a window. A window with no prices on it IS still an answer,
|
|
377
|
+
// and the one that matters most: a guest told "no type here has three left"
|
|
378
|
+
// wants to know whether another night would do, and seven days reading Full
|
|
379
|
+
// say no in a way a missing window does not.
|
|
380
|
+
if (dates.length < 2)
|
|
381
|
+
return { structured: {}, text: '' };
|
|
382
|
+
const nightCount = nightsBetween(stay.checkIn, stay.checkOut);
|
|
383
|
+
const sameNights = `the same ${nightCount} ${nightCount === 1 ? 'night' : 'nights'}`;
|
|
384
|
+
// Cheapest first; among equals the one closest to the dates that were asked
|
|
385
|
+
// about, because moving four days to save nothing is not an offer either.
|
|
386
|
+
const shift = (d) => Math.abs(Date.parse(d.checkIn) - Date.parse(stay.checkIn));
|
|
387
|
+
const best = others
|
|
388
|
+
.slice()
|
|
389
|
+
.sort((a, b) => (a.from?.minor ?? 0) - (b.from?.minor ?? 0) || shift(a) - shift(b))[0];
|
|
390
|
+
// ⚠️ THE MARK IS EARNED AGAINST THE GUEST'S OWN DATES, not against the rest
|
|
391
|
+
// of the window. Whatever is lowest is always lowest; badging it would put a
|
|
392
|
+
// bargain flag on the dates the guest already chose, or on a date four days
|
|
393
|
+
// away that saves nothing.
|
|
394
|
+
//
|
|
395
|
+
// ⚠️ AND EVERY DATE THAT TIES IS MARKED. Three weekdays at one rate is the
|
|
396
|
+
// normal shape of a hotel week; marking only the closest of them would say
|
|
397
|
+
// the other two are worse, which is a claim about prices that are equal.
|
|
398
|
+
const beats = best?.from && chosen?.from && best.from.minor < chosen.from.minor ? best : undefined;
|
|
399
|
+
const beatsBy = beats?.from?.minor;
|
|
400
|
+
// The cheapest of the window - the chosen date too - when two or more are
|
|
401
|
+
// priced in one currency; ties all marked. `best` stays what it was: a date
|
|
402
|
+
// that beats the guest's own.
|
|
403
|
+
const priced = dates.filter((d) => d.from);
|
|
404
|
+
const lowest = priced.length >= 2 && new Set(priced.map((d) => d.from?.currency)).size === 1
|
|
405
|
+
? Math.min(...priced.map((d) => d.from?.minor ?? Number.POSITIVE_INFINITY))
|
|
406
|
+
: undefined;
|
|
407
|
+
const structured = {
|
|
408
|
+
dates: dates.map((d) => ({
|
|
409
|
+
checkIn: d.checkIn,
|
|
410
|
+
checkOut: d.checkOut,
|
|
411
|
+
// "Sold out" only when it is (D2, robin 2026-10-30): a day with rooms
|
|
412
|
+
// that cannot be booked here says why instead.
|
|
413
|
+
...(d.from
|
|
414
|
+
? { from: formatMoney(d.from) }
|
|
415
|
+
: !d.why || d.why === 'sold-out'
|
|
416
|
+
? { soldOut: true }
|
|
417
|
+
: { noRoomsCode: d.why }),
|
|
418
|
+
...(d.chosen ? { chosen: true } : {}),
|
|
419
|
+
// The chosen date cannot match: `beatsBy` is a price strictly below it.
|
|
420
|
+
...(beatsBy !== undefined && d.from?.minor === beatsBy ? { best: true } : {}),
|
|
421
|
+
...(lowest !== undefined && d.from?.minor === lowest ? { lowest: true } : {}),
|
|
422
|
+
})),
|
|
423
|
+
};
|
|
424
|
+
if (!best?.from)
|
|
425
|
+
return { structured, text: '' };
|
|
426
|
+
if (!chosen?.from) {
|
|
427
|
+
return {
|
|
428
|
+
structured,
|
|
429
|
+
text: `${best.checkIn} is free for ${sameNights}, from ${formatMoney(best.from)}.`,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
if (!beats?.from)
|
|
433
|
+
return { structured, text: '' };
|
|
434
|
+
const saved = money(chosen.from.minor - beats.from.minor, chosen.from.currency);
|
|
435
|
+
return {
|
|
436
|
+
structured,
|
|
437
|
+
text: `Arriving ${beats.checkIn} instead is ${formatMoney(saved)} less for ${sameNights}.`,
|
|
438
|
+
};
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* The room types a guest can no longer book on these nights - for the card to
|
|
442
|
+
* say so, and not leave them out (r10 #10: a type the guest saw earlier
|
|
443
|
+
* vanished from the list, and the heading counted one fewer, without a word).
|
|
444
|
+
*
|
|
445
|
+
* ⚠️ AN ADDITIVE FIELD, NEVER THE TEXT. What the assistant is told is the rooms
|
|
446
|
+
* that can be booked, as before; this is only what the card draws, muted, at
|
|
447
|
+
* the end of the list. A type is listed when
|
|
448
|
+
* - the backend sends it with none left (`HotelDetail.soldOut`, or a room with
|
|
449
|
+
* `roomsLeft: 0`), or
|
|
450
|
+
* - it has some left, but fewer than the rooms asked for (`left`): a guest who
|
|
451
|
+
* asked for two rooms and was shown no type with one left was not told why.
|
|
452
|
+
* Not a type that sleeps fewer than the party (the backend never sends it), and
|
|
453
|
+
* not a type any of whose rates can be booked. One entry a type, with the facts
|
|
454
|
+
* the card says of a room and no price.
|
|
455
|
+
*/
|
|
456
|
+
export const soldOutTypesOf = (detail, enough, wanted) => {
|
|
457
|
+
const key = (r) => r.roomType?.id ?? r.id;
|
|
458
|
+
const open = new Set(enough.map(key));
|
|
459
|
+
const types = new Map();
|
|
460
|
+
for (const r of [...(detail.rooms ?? []), ...(detail.soldOut ?? [])]) {
|
|
461
|
+
if (r.hourly || open.has(key(r)) || r.roomsLeft >= wanted)
|
|
462
|
+
continue;
|
|
463
|
+
const seen = types.get(key(r));
|
|
464
|
+
if (seen)
|
|
465
|
+
seen.left = Math.max(seen.left, r.roomsLeft);
|
|
466
|
+
else
|
|
467
|
+
types.set(key(r), { room: r, left: r.roomsLeft });
|
|
468
|
+
}
|
|
469
|
+
return [...types.entries()].map(([id, { room: r, left }]) => ({
|
|
470
|
+
id,
|
|
471
|
+
name: r.roomType?.name ?? r.name,
|
|
472
|
+
...((r.roomType?.names ?? r.names) ? { names: r.roomType?.names ?? r.names } : {}),
|
|
473
|
+
sleeps: r.sleeps,
|
|
474
|
+
...(r.maxChildren ? { maxChildren: r.maxChildren } : {}),
|
|
475
|
+
...(r.sizeSqm ? { sizeSqm: r.sizeSqm } : {}),
|
|
476
|
+
...(r.beds ? { beds: r.beds } : {}),
|
|
477
|
+
...(r.bedTypes ? { bedTypes: r.bedTypes } : {}),
|
|
478
|
+
...(r.view ? { view: r.view } : {}),
|
|
479
|
+
...(r.window ? { window: r.window } : {}),
|
|
480
|
+
...(r.floor ? { floor: r.floor } : {}),
|
|
481
|
+
...(r.wifi ? { wifi: true } : {}),
|
|
482
|
+
...(r.extraBed ? { extraBed: true } : {}),
|
|
483
|
+
...(r.imageUrl ? { imageUrl: r.imageUrl } : {}),
|
|
484
|
+
// Some left, but not as many as were asked for.
|
|
485
|
+
...(left > 0 ? { left } : {}),
|
|
486
|
+
}));
|
|
487
|
+
};
|
|
488
|
+
/** A code that opens no booking here: where orders are the account's, no email would have opened it. */
|
|
489
|
+
export const noBookingLike = (deps) => ordersByAccount(deps.backend.capabilities ?? FULL_CAPABILITIES)
|
|
490
|
+
? 'No booking here matches that code. Only bookings made here by this account are known.'
|
|
491
|
+
: 'No booking here matches that code. A booking made in another conversation needs the email it was made with.';
|
|
492
|
+
//# sourceMappingURL=terms-answer.js.map
|