@curless/hotel-storefront 0.84.2 → 0.84.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/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 +7 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/otaless/addons-answers.d.ts.map +1 -1
- package/dist/otaless/addons-answers.js +15 -1
- package/dist/otaless/addons-answers.js.map +1 -1
- package/dist/otaless/addons.d.ts +26 -1
- package/dist/otaless/addons.d.ts.map +1 -1
- package/dist/otaless/addons.js +128 -35
- package/dist/otaless/addons.js.map +1 -1
- package/dist/otaless/shop-fake.d.ts +8 -0
- package/dist/otaless/shop-fake.d.ts.map +1 -1
- package/dist/otaless/shop-fake.js +5 -3
- package/dist/otaless/shop-fake.js.map +1 -1
- package/dist/otaless/shop-ids.d.ts +26 -0
- package/dist/otaless/shop-ids.d.ts.map +1 -0
- package/dist/otaless/shop-ids.js +49 -0
- package/dist/otaless/shop-ids.js.map +1 -0
- package/dist/otaless/shop-record.d.ts.map +1 -1
- package/dist/otaless/shop-record.js +27 -9
- package/dist/otaless/shop-record.js.map +1 -1
- package/dist/otaless/shop-service.d.ts +31 -18
- package/dist/otaless/shop-service.d.ts.map +1 -1
- package/dist/otaless/shop-service.js +38 -18
- package/dist/otaless/shop-service.js.map +1 -1
- package/dist/otaless/shop.d.ts +25 -7
- package/dist/otaless/shop.d.ts.map +1 -1
- package/dist/otaless/shop.js +76 -27
- package/dist/otaless/shop.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/tools.d.ts +5 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +43 -5
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -4944,6 +4944,40 @@ const termsAnswer = (deps, ctx, key, terms) => {
|
|
|
4944
4944
|
: {}),
|
|
4945
4945
|
};
|
|
4946
4946
|
};
|
|
4947
|
+
/**
|
|
4948
|
+
* ⚠️ THE BOOKINGS IN TIME AND STATE (0.84.4, `data.bookingsByTime`; robin 11-25: 「我的预订也改一下,没必要按照
|
|
4949
|
+
* 酒店集团来分类,应该是按照时间和状态来,还有搜索」): the card's own order, in words - to pay; still to come,
|
|
4950
|
+
* soonest check-in first; stayed, latest first; cancelled, expired or not made, latest first - each part
|
|
4951
|
+
* headed with how many, each booking's line (with its state) as ever. A guest asking for one hotel's
|
|
4952
|
+
* booking is answered from these lines: every one names its hotel (and its Chinese name) and its code.
|
|
4953
|
+
* "Stayed" is a check-out before today in UTC - a day out at most at either end of the world.
|
|
4954
|
+
*/
|
|
4955
|
+
const bookingsInTime = (list, line, now) => {
|
|
4956
|
+
const today = new Date(now).toISOString().slice(0, 10);
|
|
4957
|
+
const kind = (b) => b.status === 'cancelled' || b.status === 'expired' || b.status === 'failed'
|
|
4958
|
+
? 'off'
|
|
4959
|
+
: b.stay?.checkOut && b.stay.checkOut < today
|
|
4960
|
+
? 'past'
|
|
4961
|
+
: b.status === 'awaiting-payment'
|
|
4962
|
+
? 'pay'
|
|
4963
|
+
: 'up';
|
|
4964
|
+
const ci = (b) => String(b.stay?.checkIn ?? '');
|
|
4965
|
+
const heads = {
|
|
4966
|
+
pay: 'To pay',
|
|
4967
|
+
up: 'Upcoming stays - soonest check-in first',
|
|
4968
|
+
past: 'Stayed - latest first',
|
|
4969
|
+
off: 'Cancelled, expired or not made - latest first',
|
|
4970
|
+
};
|
|
4971
|
+
return ['pay', 'up', 'past', 'off']
|
|
4972
|
+
.map((k) => {
|
|
4973
|
+
const part = list
|
|
4974
|
+
.filter((b) => kind(b) === k)
|
|
4975
|
+
.sort((a, b) => k === 'pay' || k === 'up' ? ci(a).localeCompare(ci(b)) : ci(b).localeCompare(ci(a)));
|
|
4976
|
+
return part.length ? [`${heads[k]} (${part.length}):`, ...part.map(line)].join('\n') : '';
|
|
4977
|
+
})
|
|
4978
|
+
.filter(Boolean)
|
|
4979
|
+
.join('\n');
|
|
4980
|
+
};
|
|
4947
4981
|
const bookingLine = (deps, b, noCards) => {
|
|
4948
4982
|
const kinds = b.requests?.kinds ?? [];
|
|
4949
4983
|
const held = noCards ? heldRoomsWords(b) : '';
|
|
@@ -9590,11 +9624,15 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
9590
9624
|
text: [
|
|
9591
9625
|
missed ? missLine : '',
|
|
9592
9626
|
bookings.length
|
|
9593
|
-
?
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9627
|
+
? deps.bookingsByTime
|
|
9628
|
+
? bookingsInTime(bookings, (b) => [bookingLine(deps, b, ctx.noCards), shopPart?.under.get(b.confirmationCode) ?? '']
|
|
9629
|
+
.filter(Boolean)
|
|
9630
|
+
.join('\n'), deps.trips.now())
|
|
9631
|
+
: bookings
|
|
9632
|
+
.map((b) => [bookingLine(deps, b, ctx.noCards), shopPart?.under.get(b.confirmationCode) ?? '']
|
|
9633
|
+
.filter(Boolean)
|
|
9634
|
+
.join('\n'))
|
|
9635
|
+
.join('\n')
|
|
9598
9636
|
: code
|
|
9599
9637
|
? ''
|
|
9600
9638
|
: // ⚠️ NOT "NO BOOKINGS" when a group did not answer: it may hold them.
|