@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/tools.js
CHANGED
|
@@ -1263,6 +1263,8 @@ const CANCEL_SCHEMA = {
|
|
|
1263
1263
|
view: { enum: ['cancellation-preview', 'cancelled', 'booking-not-found', 'error'] },
|
|
1264
1264
|
/** The fee is not known before the group cancels: `rule` is its terms and no fee is said. */
|
|
1265
1265
|
feeUnknown: BOOL,
|
|
1266
|
+
/** The group answered with terms the guest has not agreed to: `rule` is ours, not the group's (0.74.5). */
|
|
1267
|
+
termsNew: BOOL,
|
|
1266
1268
|
error: STR,
|
|
1267
1269
|
detail: STR,
|
|
1268
1270
|
groups: ARR,
|
|
@@ -1572,6 +1574,8 @@ export const buildOutputSchemas = (n) => ({
|
|
|
1572
1574
|
quietSaid: STR,
|
|
1573
1575
|
/** Nothing found because nothing could be read - every group silent or held back (0.59.0, U4). */
|
|
1574
1576
|
unread: BOOL,
|
|
1577
|
+
/** A group looked up only with a place, chosen with none: it, and the cities it is known to be in (0.74.6). */
|
|
1578
|
+
placeFirst: OBJ,
|
|
1575
1579
|
/** What was asked and not done, in the backend's own sentences - a limit of ours, too. */
|
|
1576
1580
|
unapplied: STRS,
|
|
1577
1581
|
/** In a market: the place asked for, when it was not recognised - the hotels are not that place's (`unplacedOf`). */
|
|
@@ -4292,6 +4296,13 @@ const listAnd = (xs) => xs.length > 1 ? `${xs.slice(0, -1).join(', ')} and ${xs.
|
|
|
4292
4296
|
const askLater = (card) => card
|
|
4293
4297
|
? 'Do not look again in this turn - no second call for it: tell the guest, who can press Try again (重试) on the card when they want to look again.'
|
|
4294
4298
|
: 'Do not look again in this turn - no second call for it: tell the guest, and that they can ask you to look again later.';
|
|
4299
|
+
/** The groups a failed stay names (Otaless's `link-first`, 0.74.5) - codes only. */
|
|
4300
|
+
const groupsOfFailed = (f) => {
|
|
4301
|
+
const g = f.groups;
|
|
4302
|
+
return Array.isArray(g)
|
|
4303
|
+
? [...new Set(g.filter((x) => typeof x === 'string' && !!x))]
|
|
4304
|
+
: [];
|
|
4305
|
+
};
|
|
4295
4306
|
/** No group kept quiet about - `degradedOf`'s default. */
|
|
4296
4307
|
const NONE_QUIET = new Set();
|
|
4297
4308
|
/**
|
|
@@ -4351,20 +4362,20 @@ hush = false) => {
|
|
|
4351
4362
|
// In the market's own order: a group kept quiet beside one said softly is one sentence.
|
|
4352
4363
|
const factSilent = all.filter((d) => d.why !== 'needs-place' && (quiet.has(d.supplier) || softly(d)));
|
|
4353
4364
|
const hushedUnplaced = hushed.filter((d) => d.why === 'needs-place');
|
|
4354
|
-
const factOf = all.filter((d) => quiet.has(d.supplier) || softly(d));
|
|
4355
4365
|
const noneOf = (n) => `so none of ${n === 1 ? 'its' : 'their'} ${noun} is in this list`;
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4366
|
+
// ⚠️ A GROUP LOOKED UP ONLY WITH A PLACE IS ONE THE GUEST CAN STILL HAVE (0.74.6, robin 11-17
|
|
4367
|
+
// (a): Accor on the home is a chip, pressed it asks for a country or a city): asked about it,
|
|
4368
|
+
// the model asks which country or city - with the cities it is known to have hotels in.
|
|
4369
|
+
const quietSaid = [
|
|
4370
|
+
factSilent.length
|
|
4371
|
+
? `${listAnd(factSilent.map(named))} did not answer this time, ${noneOf(factSilent.length)}; mention this only if the guest asks about ${listOrWords(factSilent.map(named))}.`
|
|
4372
|
+
: '',
|
|
4373
|
+
hushedUnplaced.length
|
|
4374
|
+
? `${listAnd(hushedUnplaced.map(named))} ${hushedUnplaced.length === 1 ? 'is' : 'are'} looked up only once a country or a city is named, ${noneOf(hushedUnplaced.length)}; if the guest asks about ${listOrWords(hushedUnplaced.map(named))}, ask which country or city${placesWords(hushedUnplaced, named)}.`
|
|
4375
|
+
: '',
|
|
4376
|
+
]
|
|
4377
|
+
.filter(Boolean)
|
|
4378
|
+
.join(' ');
|
|
4368
4379
|
const quietPart = {
|
|
4369
4380
|
...(hushed.length
|
|
4370
4381
|
? {
|
|
@@ -4400,7 +4411,7 @@ hush = false) => {
|
|
|
4400
4411
|
}
|
|
4401
4412
|
if (unplaced.length) {
|
|
4402
4413
|
const one = unplaced.length === 1;
|
|
4403
|
-
parts.push(`${saidOf(unplaced)} ${one ? 'is' : 'are'} looked up only once a country or a city is named - name
|
|
4414
|
+
parts.push(`${saidOf(unplaced)} ${one ? 'is' : 'are'} looked up only once a country or a city is named - ask the guest which country or city${placesWords(unplaced, (d) => withZh(d.name, d.names, noCards))}, and name it to see ${one ? 'its' : 'their'} ${noun}.`);
|
|
4404
4415
|
}
|
|
4405
4416
|
const said = parts.join(' ');
|
|
4406
4417
|
return {
|
|
@@ -4412,6 +4423,18 @@ hush = false) => {
|
|
|
4412
4423
|
said: [said, quietSaid].filter(Boolean).join(' '),
|
|
4413
4424
|
};
|
|
4414
4425
|
};
|
|
4426
|
+
/**
|
|
4427
|
+
* " (Accor has hotels in Singapore, Paris and Tokyo, among others)" - the cities a group looked
|
|
4428
|
+
* up only with a place is known to have hotels in (`Unanswered.places`, 0.74.6), or nothing.
|
|
4429
|
+
*/
|
|
4430
|
+
const placesWords = (groups,
|
|
4431
|
+
/** The group as the rest of the sentence names it (with its Chinese name to a host with no card). */
|
|
4432
|
+
named = (g) => g.name) => {
|
|
4433
|
+
const said = groups
|
|
4434
|
+
.filter((g) => g.places?.length)
|
|
4435
|
+
.map((g) => `${named(g)} has hotels in ${listAnd((g.places ?? []).map((p) => p.name))}`);
|
|
4436
|
+
return said.length ? ` (${said.join('; ')}, among others)` : '';
|
|
4437
|
+
};
|
|
4415
4438
|
/**
|
|
4416
4439
|
* The groups a search keeps quiet about (`ToolDeps.quietGroups`) - less the one
|
|
4417
4440
|
* the guest asked for (`filters.supplier`): a list of Accor's own hotels that
|
|
@@ -6321,6 +6344,8 @@ const bookingAnswer = async (deps, t, ctx, key, store, args, inTrip, lines, show
|
|
|
6321
6344
|
why: f.why,
|
|
6322
6345
|
...(f.code ? { code: f.code } : {}),
|
|
6323
6346
|
...(f.args ? { args: f.args } : {}),
|
|
6347
|
+
// The group a link is asked of (0.74.5, `link-first`): the card's Link button names it.
|
|
6348
|
+
...(groupsOfFailed(f).length ? { groups: groupsOfFailed(f) } : {}),
|
|
6324
6349
|
...(instead[i]?.city ? { city: instead[i]?.city } : {}),
|
|
6325
6350
|
alternatives: (instead[i]?.hotels ?? []).map((h) => ({
|
|
6326
6351
|
hotelId: h.id,
|
|
@@ -6336,7 +6361,22 @@ const bookingAnswer = async (deps, t, ctx, key, store, args, inTrip, lines, show
|
|
|
6336
6361
|
: {}),
|
|
6337
6362
|
})),
|
|
6338
6363
|
}));
|
|
6339
|
-
|
|
6364
|
+
// A stay refused for a link or the account's sign-in (0.74.5): the tool for it, as a booking
|
|
6365
|
+
// refused for that alone says (`refusalAnswer`).
|
|
6366
|
+
const signInFor = (f) => {
|
|
6367
|
+
const how = deps.groupSignIn;
|
|
6368
|
+
if (f.code === 'link-first' && how?.linkTool)
|
|
6369
|
+
return (f.groups ?? [])
|
|
6370
|
+
.map((code) => {
|
|
6371
|
+
const name = deps.backend.suppliers?.().find((x) => x.id === code)?.name ?? code;
|
|
6372
|
+
return ` To link the guest's ${name} membership: ${how.linkTool} with group "${code}" gives the guest a one-time page for it.`;
|
|
6373
|
+
})
|
|
6374
|
+
.join('');
|
|
6375
|
+
if ((f.code === 'sign-in' || f.code === 'signed-out') && how?.signInTool)
|
|
6376
|
+
return ` ${how.signInTool} gives the guest a one-time page to sign in to their ${deps.vocab.brand} account.`;
|
|
6377
|
+
return '';
|
|
6378
|
+
};
|
|
6379
|
+
const failedText = notBooked.map((f) => `NOT BOOKED - ${f.hotelName} · ${stayWords(f.stay, f.hourly)}: ${f.why}${signInFor(f)} It is still in the trip.${f.alternatives.length
|
|
6340
6380
|
? ` Bookable instead for the same nights: ${f.alternatives.map((a) => `${a.name}${a.room ? ` (${a.room}` : ''}${a.total ? `${a.room ? ', ' : ' ('}${a.total} for the stay)` : a.room ? ')' : ''} [hotel \`${a.hotelId}\`]`).join('; ')}.`
|
|
6341
6381
|
: ''} The guest can ask again, take another hotel, or leave it.`);
|
|
6342
6382
|
// Terms waiting for the guest, said first: that is what needs doing.
|
|
@@ -6765,7 +6805,17 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
6765
6805
|
: h);
|
|
6766
6806
|
const offset = asked.offset ?? 0;
|
|
6767
6807
|
const total = Math.max(answer.total, offset + hotels.length);
|
|
6768
|
-
|
|
6808
|
+
// One city however its group writes it (0.74.5: Accor's "SINGAPORE" beside "Singapore").
|
|
6809
|
+
const cities = [
|
|
6810
|
+
...hotels
|
|
6811
|
+
.reduce((m, h) => {
|
|
6812
|
+
const k = h.city.trim().toLowerCase();
|
|
6813
|
+
if (!m.has(k))
|
|
6814
|
+
m.set(k, h.city);
|
|
6815
|
+
return m;
|
|
6816
|
+
}, new Map())
|
|
6817
|
+
.values(),
|
|
6818
|
+
];
|
|
6769
6819
|
// How many were left behind. The group has ninety-odd properties, so an
|
|
6770
6820
|
// unnarrowed browse is a page of a much longer list, and neither the card
|
|
6771
6821
|
// nor the model may present the page as the whole answer.
|
|
@@ -7080,7 +7130,25 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7080
7130
|
// the card offered another city. What was not asked, or not answered, is
|
|
7081
7131
|
// said as that; what our limit held back is said in its own words
|
|
7082
7132
|
// (`unapplied`), which this branch did not read.
|
|
7083
|
-
|
|
7133
|
+
// ⚠️ A GROUP LOOKED UP ONLY WITH A PLACE, CHOSEN WITH NONE (0.74.6, robin 11-17 (a): Accor's
|
|
7134
|
+
// chip on the home): not "nothing could be read" - the page to choose its country or city
|
|
7135
|
+
// on, with the cities it is known to have hotels in (`Unanswered.places`). An older card
|
|
7136
|
+
// draws the empty list it drew before, its words the same.
|
|
7137
|
+
const unplacedGroup = !emptyOfItself && !asked.city && !asked.query && asked.filters?.supplier
|
|
7138
|
+
? answer.degraded?.find((d) => d.supplier === asked.filters?.supplier && d.why === 'needs-place')
|
|
7139
|
+
: undefined;
|
|
7140
|
+
const placeFirst = unplacedGroup
|
|
7141
|
+
? {
|
|
7142
|
+
supplier: unplacedGroup.supplier,
|
|
7143
|
+
name: unplacedGroup.name,
|
|
7144
|
+
...(unplacedGroup.names ? { names: unplacedGroup.names } : {}),
|
|
7145
|
+
places: (unplacedGroup.places ?? []).map((p) => ({
|
|
7146
|
+
name: p.name,
|
|
7147
|
+
...(p.names ? { names: p.names } : {}),
|
|
7148
|
+
})),
|
|
7149
|
+
}
|
|
7150
|
+
: undefined;
|
|
7151
|
+
const unread = !emptyOfItself && !placeFirst && !!degraded.structured.degraded;
|
|
7084
7152
|
const why = pastTheEnd
|
|
7085
7153
|
? `That page is past the end: ${answer.total} match, so \`offset\` 0 to ${answer.total - 1} is where they are.`
|
|
7086
7154
|
: filteredEmpty
|
|
@@ -7089,16 +7157,18 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7089
7157
|
? `Nothing under ${cap} a night. The cheapest that matched is ${first?.name} at ${cheapest ? formatMoney(cheapest) : '-'}${answer.overBudget && answer.overBudget > 1 ? `, of ${answer.overBudget} over the ceiling` : ''}.`
|
|
7090
7158
|
: ceilingEmpty
|
|
7091
7159
|
? `None of the ${answer.beforeCeiling} that match has a room for those nights.`
|
|
7092
|
-
:
|
|
7093
|
-
?
|
|
7094
|
-
:
|
|
7095
|
-
`No ${branded(deps.vocab, deps.vocab.nounPlural)}
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7160
|
+
: placeFirst
|
|
7161
|
+
? `${withZh(placeFirst.name, placeFirst.names, ctx?.noCards)}'s ${deps.vocab.nounPlural} are looked up by country or city, and none was named.`
|
|
7162
|
+
: unread
|
|
7163
|
+
? `No ${branded(deps.vocab, deps.vocab.nounPlural)} could be read this time.`
|
|
7164
|
+
: [
|
|
7165
|
+
`No ${branded(deps.vocab, deps.vocab.nounPlural)} match that.`,
|
|
7166
|
+
// What was tried and also failed is worth a sentence: it tells a
|
|
7167
|
+
// guest the word itself is the problem, not the narrowing.
|
|
7168
|
+
widened ? `${sentence(widened.to)} found nothing either.` : '',
|
|
7169
|
+
]
|
|
7170
|
+
.filter(Boolean)
|
|
7171
|
+
.join(' ');
|
|
7102
7172
|
return {
|
|
7103
7173
|
structured: {
|
|
7104
7174
|
view: 'no-hotels',
|
|
@@ -7113,6 +7183,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7113
7183
|
...degraded.structured,
|
|
7114
7184
|
// Nothing read at all: the card says so, with 「重试」, not "try another city" (U4).
|
|
7115
7185
|
...(unread ? { unread: true } : {}),
|
|
7186
|
+
// The group to choose a place for, and the cities it is known to be in (0.74.6).
|
|
7187
|
+
...(placeFirst ? { placeFirst } : {}),
|
|
7116
7188
|
...(answer.unapplied?.length ? { unapplied: answer.unapplied } : {}),
|
|
7117
7189
|
// Why it is empty, in the words the model is told, so the card says
|
|
7118
7190
|
// the same thing rather than guessing at it.
|
|
@@ -8581,6 +8653,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
8581
8653
|
// ⚠️ THE FEE IS NOT KNOWN BEFORE THE GROUP CANCELS (`feeUnknown`): the rule is
|
|
8582
8654
|
// the group's own terms, and no figure - not even "up to" - is said.
|
|
8583
8655
|
...(preview.feeUnknown ? { feeUnknown: true } : { fee: formatMoney(preview.fee) }),
|
|
8656
|
+
// Its `rule` is ours, for the model (0.74.5): the card says it in its own words.
|
|
8657
|
+
...(preview.termsNew ? { termsNew: true } : {}),
|
|
8584
8658
|
// What the booking came to, so the fee is read against it (r10 #22).
|
|
8585
8659
|
...(booked ? { bookingTotal: formatMoney(booked.quote.total) } : {}),
|
|
8586
8660
|
// ⚠️ NO "REFUND": nothing was ever paid here - a demonstration takes no
|