@curless/hotel-storefront 0.69.1 → 0.69.3
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/backend.d.ts +7 -0
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.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/huazhu/english.d.ts.map +1 -1
- package/dist/huazhu/english.js +10 -0
- package/dist/huazhu/english.js.map +1 -1
- package/dist/legal.d.ts +7 -4
- package/dist/legal.d.ts.map +1 -1
- package/dist/legal.js +14 -6
- package/dist/legal.js.map +1 -1
- package/dist/otaless/backend.d.ts.map +1 -1
- package/dist/otaless/backend.js +105 -30
- package/dist/otaless/backend.js.map +1 -1
- package/dist/otaless/booking.d.ts +8 -0
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +46 -9
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/fake.d.ts +8 -0
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +5 -3
- package/dist/otaless/fake.js.map +1 -1
- package/dist/otaless/places.d.ts +19 -0
- package/dist/otaless/places.d.ts.map +1 -1
- package/dist/otaless/places.js +57 -1
- package/dist/otaless/places.js.map +1 -1
- package/dist/present.d.ts +10 -2
- package/dist/present.d.ts.map +1 -1
- package/dist/present.js +12 -3
- package/dist/present.js.map +1 -1
- package/dist/ranges-check.d.ts +14 -0
- package/dist/ranges-check.d.ts.map +1 -1
- package/dist/ranges-check.js +70 -7
- package/dist/ranges-check.js.map +1 -1
- package/dist/server.d.ts +5 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +111 -21
- package/dist/server.js.map +1 -1
- package/dist/source-allowlist.d.ts +75 -1
- package/dist/source-allowlist.d.ts.map +1 -1
- package/dist/source-allowlist.js +332 -18
- package/dist/source-allowlist.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +93 -6
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -2028,10 +2028,16 @@ const alternativesFor = async (deps, f, lines, shown, who) => {
|
|
|
2028
2028
|
}
|
|
2029
2029
|
};
|
|
2030
2030
|
const groupNamed = (deps, said) => {
|
|
2031
|
+
const all = deps.backend.suppliers?.() ?? [];
|
|
2032
|
+
// The market's own reading first - its groups' other names (酒店对接 11-12, `supplierNamed`).
|
|
2033
|
+
const id = deps.backend.supplierNamed?.(said);
|
|
2034
|
+
const byMarket = id ? all.find((x) => x.id === id) : undefined;
|
|
2035
|
+
if (byMarket)
|
|
2036
|
+
return byMarket;
|
|
2031
2037
|
const want = said.trim().toLowerCase();
|
|
2032
|
-
return
|
|
2033
|
-
.
|
|
2034
|
-
.
|
|
2038
|
+
return all.find((x) => x.id.toLowerCase() === want ||
|
|
2039
|
+
x.name.toLowerCase() === want ||
|
|
2040
|
+
Object.values(x.names ?? {}).some((n) => n?.trim().toLowerCase() === want));
|
|
2035
2041
|
};
|
|
2036
2042
|
/** The same trip line at a count of nothing - which takes it out (`TripStore.set`). */
|
|
2037
2043
|
const unset = (l) => l.kind === 'extra' ? { ...l, quantity: 0 } : { ...l, rooms: 0 };
|
|
@@ -4387,6 +4393,84 @@ const guarded = async (deps, ctx, who, code, run) => {
|
|
|
4387
4393
|
deps.misses?.miss(keys);
|
|
4388
4394
|
return { found, tooMany: false };
|
|
4389
4395
|
};
|
|
4396
|
+
/**
|
|
4397
|
+
* The trip's lines priced, one quote per currency THE QUOTES ARE IN.
|
|
4398
|
+
*
|
|
4399
|
+
* ⚠️ A HOTEL'S LISTED CURRENCY IS NOT THE CURRENCY OF ITS QUOTE (总线程 11-12, questions
|
|
4400
|
+
* #45 / #67; docs/otaless-hotels.md §15.20, §15.21): a hotel listed in USD can quote CNY.
|
|
4401
|
+
* Grouped by the list's currency, it went into one group with a hotel that quotes USD and
|
|
4402
|
+
* the backend refused the whole group as `mixed-currency` - the trip could not be priced -
|
|
4403
|
+
* and two hotels that both quote CNY but are listed in two currencies came out as two
|
|
4404
|
+
* "CNY" parts, a trip said to be in two currencies that are one. The list's currency is
|
|
4405
|
+
* for showing a starting price; what a line costs is in what it was quoted in.
|
|
4406
|
+
*
|
|
4407
|
+
* The trip is first priced by the list's currencies, as before: when that gives one part
|
|
4408
|
+
* per quote currency - the usual trip, listed as quoted - it is the answer, unchanged.
|
|
4409
|
+
* Only when a group is refused as mixed, or two parts turn out to be in one currency, is
|
|
4410
|
+
* each line quoted on its own to read its currency, and the lines grouped by it and priced
|
|
4411
|
+
* again. Same currency lines are priced together (the backend adds them); other currencies
|
|
4412
|
+
* are never added, nor converted.
|
|
4413
|
+
*/
|
|
4414
|
+
const pricedByQuoteCurrency = async (deps, all, listed, asked, who) => {
|
|
4415
|
+
let first;
|
|
4416
|
+
let refused;
|
|
4417
|
+
try {
|
|
4418
|
+
first = await Promise.all(listed.map((g) => deps.backend.quote({ lines: g, ...asked }, who)));
|
|
4419
|
+
}
|
|
4420
|
+
catch (err) {
|
|
4421
|
+
if (err.code !== 'mixed-currency')
|
|
4422
|
+
throw err;
|
|
4423
|
+
refused = err;
|
|
4424
|
+
}
|
|
4425
|
+
if (first) {
|
|
4426
|
+
// A part with nothing priced has no currency of its own to compare.
|
|
4427
|
+
const seen = first.filter((p) => p.lines.length).map((p) => p.total.currency);
|
|
4428
|
+
if (new Set(seen).size === seen.length)
|
|
4429
|
+
return first;
|
|
4430
|
+
}
|
|
4431
|
+
const inTrip = new Set(listed.flat());
|
|
4432
|
+
const lines = all.filter((l) => inTrip.has(l));
|
|
4433
|
+
// Each line on its own, without the coupon: this only reads the currency it is quoted in.
|
|
4434
|
+
const probes = await Promise.all(lines.map((l) => deps.backend.quote({ lines: [l] }, who)));
|
|
4435
|
+
const currencyOf = new Map();
|
|
4436
|
+
lines.forEach((l, i) => {
|
|
4437
|
+
const q = probes[i];
|
|
4438
|
+
if (q?.lines.length)
|
|
4439
|
+
currencyOf.set(l, q.total.currency);
|
|
4440
|
+
});
|
|
4441
|
+
const groups = new Map();
|
|
4442
|
+
for (const l of lines) {
|
|
4443
|
+
const c = currencyOf.get(l);
|
|
4444
|
+
if (c !== undefined)
|
|
4445
|
+
groups.set(c, [...(groups.get(c) ?? []), l]);
|
|
4446
|
+
}
|
|
4447
|
+
// Nothing priced on its own (gone since the first try): the first answer stands -
|
|
4448
|
+
// or, when that was a refusal, the refusal, as before this function existed.
|
|
4449
|
+
if (groups.size === 0) {
|
|
4450
|
+
if (first)
|
|
4451
|
+
return first;
|
|
4452
|
+
throw refused;
|
|
4453
|
+
}
|
|
4454
|
+
// A line nothing was priced for (a room that went, a group that gave no price) is not a
|
|
4455
|
+
// currency of its own: it stays with its hotel's other lines, else with the group of the
|
|
4456
|
+
// hotels listed in the same currency, else with the first.
|
|
4457
|
+
const home = (l) => {
|
|
4458
|
+
for (const [c, g] of groups)
|
|
4459
|
+
if (g.some((x) => x.hotelId === l.hotelId))
|
|
4460
|
+
return c;
|
|
4461
|
+
const listedWith = listed.find((g) => g.includes(l)) ?? [];
|
|
4462
|
+
for (const [c, g] of groups)
|
|
4463
|
+
if (g.some((x) => listedWith.includes(x)))
|
|
4464
|
+
return c;
|
|
4465
|
+
return groups.keys().next().value;
|
|
4466
|
+
};
|
|
4467
|
+
const placed = new Map([...groups.keys()].map((c) => [c, []]));
|
|
4468
|
+
for (const l of lines) {
|
|
4469
|
+
const c = currencyOf.get(l) ?? home(l);
|
|
4470
|
+
placed.get(c)?.push(l);
|
|
4471
|
+
}
|
|
4472
|
+
return Promise.all([...placed.values()].map((g) => deps.backend.quote({ lines: g, ...asked }, who)));
|
|
4473
|
+
};
|
|
4390
4474
|
/**
|
|
4391
4475
|
* The trip priced one currency at a time, in the order the currencies first
|
|
4392
4476
|
* appear in it.
|
|
@@ -4422,7 +4506,7 @@ const quoteParts = async (deps, lines, who, coupon) => {
|
|
|
4422
4506
|
}
|
|
4423
4507
|
if (byCurrency.size === 0)
|
|
4424
4508
|
return [await deps.backend.quote({ lines: [], ...asked }, who)];
|
|
4425
|
-
const priced = await
|
|
4509
|
+
const priced = await pricedByQuoteCurrency(deps, lines, [...byCurrency.values()], asked, who);
|
|
4426
4510
|
const parts = unread.size && priced[0]
|
|
4427
4511
|
? [
|
|
4428
4512
|
{
|
|
@@ -8402,7 +8486,9 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
8402
8486
|
// A group that did not answer is not "not ours" (2026-11-03 review, C5):
|
|
8403
8487
|
// its hotels are said as left out for that.
|
|
8404
8488
|
const silent = comparison.dropped.filter((d) => d.code === 'supplier-timeout');
|
|
8405
|
-
|
|
8489
|
+
// A hotel with no room for the nights is one of ours too (`code` 'no-rooms'): left out, said as that.
|
|
8490
|
+
const noRooms = comparison.dropped.filter((d) => d.code === 'no-rooms');
|
|
8491
|
+
const unknown = comparison.dropped.filter((d) => !d.candidates?.length && d.code !== 'supplier-timeout' && d.code !== 'no-rooms');
|
|
8406
8492
|
const fitsMany = fitsManyOf(deps, comparison.dropped);
|
|
8407
8493
|
return {
|
|
8408
8494
|
structured: {
|
|
@@ -8412,12 +8498,13 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
8412
8498
|
},
|
|
8413
8499
|
// A name that fits several IS one of ours - only the rest are "none".
|
|
8414
8500
|
text: [
|
|
8415
|
-
...(unknown.length || (!fitsMany.length && !silent.length)
|
|
8501
|
+
...(unknown.length || (!fitsMany.length && !silent.length && !noRooms.length)
|
|
8416
8502
|
? [
|
|
8417
8503
|
`None of those are ${catalogue(deps.vocab)}: ${unknown.map((d) => d.name).join(', ')}.`,
|
|
8418
8504
|
]
|
|
8419
8505
|
: []),
|
|
8420
8506
|
...fitsMany,
|
|
8507
|
+
...noRooms.map((d) => `Left out: ${d.name} — ${d.why}`),
|
|
8421
8508
|
...silent.map((d) => `Left out: ${d.name} — ${d.why}`),
|
|
8422
8509
|
silent.length ? askLater(!ctx.noCards) : '',
|
|
8423
8510
|
]
|