@curless/hotel-storefront 0.75.2 → 0.75.4

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
@@ -16,7 +16,7 @@ import { FAMILY_SLEEPS, activeKeysOf, byRoomType, facetsOf, keyWords, matchesTer
16
16
  import { SAME_BOOKING_MS } from './same-booking.js';
17
17
  import { withTrip } from './trip-ids.js';
18
18
  import { MAX_EXTRA_QUANTITY, MAX_ROOMS_PER_LINE, clampCount, pickedKey, shownOf, stampOf, tripKey, } from './trip.js';
19
- import { branded, catalogue, upFirst } from './vocab.js';
19
+ import { branded, catalogue, keyBrandOf, upFirst } from './vocab.js';
20
20
  // The eleven things a guest can do: find hotels, look at one on dates, see what
21
21
  // else it offers, build a trip, ask for the rooms, and deal with a booking they
22
22
  // already have.
@@ -4317,7 +4317,7 @@ const noBookingLike = (deps) => ordersByAccount(deps.backend.capabilities ?? FUL
4317
4317
  const identity = (deps, ctx, key, args = {}) => {
4318
4318
  const email = str(args.email);
4319
4319
  const member = deps.members.read(key);
4320
- const own = ctx.conversation ?? tripKey(ctx.session, deps.vocab.brand);
4320
+ const own = ctx.conversation ?? tripKey(ctx.session, keyBrandOf(deps.vocab));
4321
4321
  return {
4322
4322
  // ⚠️ THE CALLER'S OWN SESSION, NEVER THE TRIP IT NAMED. This was the trip
4323
4323
  // key, so that the card - on a connection of its own - could cancel what
@@ -5421,7 +5421,7 @@ args = {}) => {
5421
5421
  * key is `tripKey(session, brand)`; the identity is the same one the tools build.
5422
5422
  */
5423
5423
  export const contextFor = (deps, key) => {
5424
- const suffix = ` ${deps.vocab.brand.toLowerCase()}`;
5424
+ const suffix = ` ${keyBrandOf(deps.vocab).toLowerCase()}`;
5425
5425
  return {
5426
5426
  session: key.endsWith(suffix) ? key.slice(0, -suffix.length) : key,
5427
5427
  tripKey: key,
@@ -5442,7 +5442,7 @@ export const handleTool = async (deps, name, rawArgs, ctx) => {
5442
5442
  const answer = await answerTool(deps, name, rawArgs, ctx).catch((err) => {
5443
5443
  // The group's checkout's refusals, from any tool that can get one (a
5444
5444
  // booking list, a cancellation, a refund, an add-on): answered with their code.
5445
- const refused = refusalAnswer(deps, ctx.tripKey ?? tripKey(ctx.session, deps.vocab.brand), err);
5445
+ const refused = refusalAnswer(deps, ctx.tripKey ?? tripKey(ctx.session, keyBrandOf(deps.vocab)), err);
5446
5446
  if (refused)
5447
5447
  return refused;
5448
5448
  const down = unansweredBy(err);
@@ -5450,9 +5450,9 @@ export const handleTool = async (deps, name, rawArgs, ctx) => {
5450
5450
  throw err;
5451
5451
  // `look_up` and the policies draw no card, so there is no 「重试」 to press.
5452
5452
  const card = !ctx.noCards && name !== deps.tools.lookUp && name !== deps.tools.policies;
5453
- return notAnswered(deps, ctx.tripKey ?? tripKey(ctx.session, deps.vocab.brand), down, card);
5453
+ return notAnswered(deps, ctx.tripKey ?? tripKey(ctx.session, keyBrandOf(deps.vocab)), down, card);
5454
5454
  });
5455
- const suggestions = await suggestionsFor(deps, answer.structured, identity(deps, ctx, ctx.tripKey ?? tripKey(ctx.session, deps.vocab.brand))).catch(() => []);
5455
+ const suggestions = await suggestionsFor(deps, answer.structured, identity(deps, ctx, ctx.tripKey ?? tripKey(ctx.session, keyBrandOf(deps.vocab)))).catch(() => []);
5456
5456
  return { answer, suggestions };
5457
5457
  });
5458
5458
  const { answer, suggestions } = result;
@@ -6798,7 +6798,7 @@ const bookTripLines = async (deps, t, ctx, key, store, args, nothingThere) => {
6798
6798
  const answerTool = async (deps, name, rawArgs, ctx) => {
6799
6799
  const args = countsAsNumbers((rawArgs ?? {}));
6800
6800
  const t = deps.tools;
6801
- const key = ctx.tripKey ?? tripKey(ctx.session, deps.vocab.brand);
6801
+ const key = ctx.tripKey ?? tripKey(ctx.session, keyBrandOf(deps.vocab));
6802
6802
  const badCount = countProblem(t, name, args);
6803
6803
  if (badCount) {
6804
6804
  return {