@curless/hotel-storefront 0.41.0 → 0.42.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/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/dates.d.ts +6 -0
- package/dist/dates.d.ts.map +1 -1
- package/dist/dates.js +30 -0
- package/dist/dates.js.map +1 -1
- package/dist/demo-hotels.d.ts.map +1 -1
- package/dist/demo-hotels.js +63 -4
- package/dist/demo-hotels.js.map +1 -1
- package/dist/huazhu/backend.d.ts.map +1 -1
- package/dist/huazhu/backend.js +32 -4
- package/dist/huazhu/backend.js.map +1 -1
- package/dist/huazhu/cancel-policy.d.ts +18 -0
- package/dist/huazhu/cancel-policy.d.ts.map +1 -1
- package/dist/huazhu/cancel-policy.js +30 -5
- package/dist/huazhu/cancel-policy.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +21 -0
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/huazhu/backend.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,YAAY,EASlB,MAAM,eAAe,CAAC;AAavB,OAAO,EAAkB,KAAK,aAAa,EAAkC,MAAM,cAAc,CAAC;AAElG,OAAO,KAAK,EAAE,QAAQ,EAAiC,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAGL,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/huazhu/backend.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,YAA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AI,MAAM,EAAE,WAAU,IAAI,GAAG,IAAW,KAAG,MAKtF,CAAC;AAiCF;;;GAGG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,UAAU,GAAG,SAAS,EAC7B,GAAG,KAAK;AACR,kGAAkG;AAClG,eAAY,KACX,MAAM,GAAG,SAwBX,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,mBAAmB,KACxB,YAAY,GAAG;IAChB,YAAY,EAAE,mBAAmB,CAAC;IAClC,YAAY,IAAI,MAAM,EAAE,CAAC;IACzB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;IACnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CA0pH9B,CAAC"}
|
package/dist/huazhu/backend.js
CHANGED
|
@@ -9,7 +9,7 @@ import { formatMoney, minorFactor, money, multiplyMoney, toMinor } from '../mone
|
|
|
9
9
|
import { UnionPayError, expiryMMyy, lastFour, } from '../payments/unionpay.js';
|
|
10
10
|
import { MAX_ROOMS_PER_LINE, quoteLineKey } from '../trip.js';
|
|
11
11
|
import { IN_REQUEST_AT_MS, NOT_FOUND, StoreWriteError, nextCheckAt, statusOf, } from './bookings.js';
|
|
12
|
-
import { describePolicy, feeFor, freeUntilOf, nightAuditOf, parseCancelPolicy, penaltyAt, refundableFrom, } from './cancel-policy.js';
|
|
12
|
+
import { describePolicy, feeFor, freeUntilOf, nightAuditOf, parseCancelPolicy, penaltyAt, refundableFrom, stepsOf, } from './cancel-policy.js';
|
|
13
13
|
import { haystackOf, inPlace, namesOf, roomPhoto, toHotel } from './catalog.js';
|
|
14
14
|
import { HuazhuRefusal, HuazhuUnreachable } from './client.js';
|
|
15
15
|
import { bedNameEn, offerNameEn, rateNameEn, roomNameEn } from './english.js';
|
|
@@ -1488,16 +1488,22 @@ export const createHuazhuHotels = (opts) => {
|
|
|
1488
1488
|
// the guest (2026-10-05 audit, P3).
|
|
1489
1489
|
rule: "This rate's cancellation terms could not be read here, so the fee shown is the most it could be. Huazhu works out the actual fee when it cancels.",
|
|
1490
1490
|
freeUntil: undefined,
|
|
1491
|
+
feeIsCap: true,
|
|
1492
|
+
steps: undefined,
|
|
1491
1493
|
};
|
|
1492
1494
|
}
|
|
1495
|
+
const startsAt = b.hourly ? arrivalInstant(b.stay.checkIn, b.hourly.start, b.tz) : undefined;
|
|
1496
|
+
const steps = stepsOf(policy, b.stay.checkIn, b.tz, amounts, at, startsAt);
|
|
1493
1497
|
// A room by the hour that has begun is a no-show, whatever the code says
|
|
1494
1498
|
// about the rest of the day - see `beforeStart`.
|
|
1495
|
-
if (
|
|
1499
|
+
if (startsAt !== undefined && at >= startsAt) {
|
|
1496
1500
|
return {
|
|
1497
1501
|
fee: total,
|
|
1498
1502
|
forbidden: false,
|
|
1499
|
-
rule: `This room by the hour began at ${b.hourly
|
|
1503
|
+
rule: `This room by the hour began at ${b.hourly?.start}, so cancelling now is a no-show; the fee shown is the most it could be, and Huazhu works out the actual fee when it cancels.`,
|
|
1500
1504
|
freeUntil: undefined,
|
|
1505
|
+
feeIsCap: true,
|
|
1506
|
+
steps,
|
|
1501
1507
|
};
|
|
1502
1508
|
}
|
|
1503
1509
|
const penalty = penaltyAt(policy, b.stay.checkIn, b.tz, at);
|
|
@@ -1512,8 +1518,21 @@ export const createHuazhuHotels = (opts) => {
|
|
|
1512
1518
|
? `Free to cancel until ${b.hourly.start} on ${b.stay.checkIn}, when the room by the hour begins; after that it is a no-show.`
|
|
1513
1519
|
: describePolicy(policy, b.stay.checkIn, b.tz, amounts),
|
|
1514
1520
|
freeUntil,
|
|
1521
|
+
feeIsCap: undefined,
|
|
1522
|
+
steps,
|
|
1515
1523
|
};
|
|
1516
1524
|
};
|
|
1525
|
+
/** `feeNow`'s steps as the card reads them: money, and the hotel's clock. */
|
|
1526
|
+
const stepsTold = (b, steps) => steps
|
|
1527
|
+
? {
|
|
1528
|
+
steps: steps.map((x) => ({
|
|
1529
|
+
...(x.until !== undefined ? { untilLocalIso: localIsoAt(x.until, b.tz) } : {}),
|
|
1530
|
+
fee: x.fee === null ? null : money(x.fee, b.quote.total.currency),
|
|
1531
|
+
...(x.noShow ? { noShow: true } : {}),
|
|
1532
|
+
...(x.current ? { current: true } : {}),
|
|
1533
|
+
})),
|
|
1534
|
+
}
|
|
1535
|
+
: {};
|
|
1517
1536
|
/**
|
|
1518
1537
|
* Chase one unanswered booking call inside the guest's request - the first
|
|
1519
1538
|
* of its checks (`IN_REQUEST_AT_MS`), on the reconciler's own schedule; the
|
|
@@ -3631,6 +3650,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
3631
3650
|
refund: zero,
|
|
3632
3651
|
rule: 'Not paid yet, and nothing is booked with Huazhu: cancelling closes the payment page, and nothing is charged.',
|
|
3633
3652
|
cancellable: true,
|
|
3653
|
+
reason: 'unpaid',
|
|
3634
3654
|
};
|
|
3635
3655
|
}
|
|
3636
3656
|
if (b.pendingSince !== undefined || b.status === 'unconfirmed') {
|
|
@@ -3641,6 +3661,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
3641
3661
|
refund: zero,
|
|
3642
3662
|
rule: waitingWords(b),
|
|
3643
3663
|
cancellable: false,
|
|
3664
|
+
reason: b.status === 'unconfirmed' ? 'unconfirmed' : 'confirming',
|
|
3644
3665
|
};
|
|
3645
3666
|
}
|
|
3646
3667
|
if (b.status !== 'confirmed' || past) {
|
|
@@ -3653,9 +3674,13 @@ export const createHuazhuHotels = (opts) => {
|
|
|
3653
3674
|
? 'The arrival day has passed; a booking cannot be cancelled after it.'
|
|
3654
3675
|
: `This booking is ${b.status}; there is nothing left to cancel.`,
|
|
3655
3676
|
cancellable: false,
|
|
3677
|
+
reason: past && b.status === 'confirmed' ? 'past-arrival' : 'not-active',
|
|
3656
3678
|
};
|
|
3657
3679
|
}
|
|
3658
|
-
const { fee, forbidden, rule, freeUntil } = feeNow(b);
|
|
3680
|
+
const { fee, forbidden, rule, freeUntil, feeIsCap, steps } = feeNow(b);
|
|
3681
|
+
// The terms as facts, for the card's own language - `rule` stays for
|
|
3682
|
+
// the model (华住 / 香格里拉, 2026-10-19).
|
|
3683
|
+
const facts = { ...(feeIsCap ? { feeIsCap } : {}), ...stepsTold(b, steps) };
|
|
3659
3684
|
// A test booking says it is one (2026-10-16 audit, P2): Huazhu's test
|
|
3660
3685
|
// system charges nobody and books nothing anyone stays in.
|
|
3661
3686
|
const testNote = opts.testEnvironment
|
|
@@ -3678,6 +3703,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
3678
3703
|
: `${rule} Paid with a UnionPay card that Huazhu charged: cancelling now gives nothing back - the fee is the whole stay, and Huazhu keeps it.${testNote}`,
|
|
3679
3704
|
...(freeUntil ? { freeUntil: new Date(freeUntil).toISOString() } : {}),
|
|
3680
3705
|
cancellable: !forbidden,
|
|
3706
|
+
...facts,
|
|
3681
3707
|
};
|
|
3682
3708
|
}
|
|
3683
3709
|
if (b.prepaid?.paidAt) {
|
|
@@ -3696,6 +3722,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
3696
3722
|
: `${rule} Cancelling now gives nothing back: the fee is the whole stay.${testNote}`,
|
|
3697
3723
|
...(freeUntil ? { freeUntil: new Date(freeUntil).toISOString() } : {}),
|
|
3698
3724
|
cancellable: !forbidden,
|
|
3725
|
+
...facts,
|
|
3699
3726
|
};
|
|
3700
3727
|
}
|
|
3701
3728
|
return {
|
|
@@ -3713,6 +3740,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
3713
3740
|
: `${rule} Nothing was paid through this connector - the booking is paid at the hotel - so any fee is charged under the hotel's terms, and Huazhu works out the exact amount when it cancels.`,
|
|
3714
3741
|
...(freeUntil ? { freeUntil: new Date(freeUntil).toISOString() } : {}),
|
|
3715
3742
|
cancellable: !forbidden,
|
|
3743
|
+
...facts,
|
|
3716
3744
|
};
|
|
3717
3745
|
},
|
|
3718
3746
|
async cancelBooking(ref, who) {
|