@curless/hotel-storefront 0.77.1 → 0.77.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/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/config.d.ts +1 -1
- package/dist/huazhu/backend.d.ts +8 -0
- package/dist/huazhu/backend.d.ts.map +1 -1
- package/dist/huazhu/backend.js +87 -5
- package/dist/huazhu/backend.js.map +1 -1
- package/dist/huazhu/catalog.d.ts +4 -2
- package/dist/huazhu/catalog.d.ts.map +1 -1
- package/dist/huazhu/catalog.js +14 -4
- package/dist/huazhu/catalog.js.map +1 -1
- package/dist/huazhu/client.d.ts +2 -2
- package/dist/huazhu/client.d.ts.map +1 -1
- package/dist/huazhu/client.js +2 -2
- package/dist/huazhu/client.js.map +1 -1
- package/dist/huazhu/fake.d.ts +2 -0
- package/dist/huazhu/fake.d.ts.map +1 -1
- package/dist/huazhu/fake.js +1 -1
- package/dist/huazhu/fake.js.map +1 -1
- package/dist/huazhu/make.js +1 -1
- package/dist/huazhu/make.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 +40 -1
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.generated.js","sourceRoot":"","sources":["../src/card.generated.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wEAAwE;AACxE,gFAAgF;AAChF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAW,MAAM,CAAC,IAAI,CAChD,
|
|
1
|
+
{"version":3,"file":"card.generated.js","sourceRoot":"","sources":["../src/card.generated.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wEAAwE;AACxE,gFAAgF;AAChF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAW,MAAM,CAAC,IAAI,CAChD,8n6mDAA8n6mD,EAC9n6mD,QAAQ,CACT,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEnB,6GAA6G;AAC7G,MAAM,CAAC,MAAM,qBAAqB,GAChC,kEAAkE,CAAC;AAErE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,qBAAqB,GAChC,iLAAiL,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -611,7 +611,7 @@ export type ApiSource = {
|
|
|
611
611
|
/**
|
|
612
612
|
* How long a read of a hotel's rates and rooms left (Huazhu's ARI: offers, inventory) is
|
|
613
613
|
* kept, in milliseconds. Whole number, 10 000 (10 seconds) to 3 600 000 (an hour).
|
|
614
|
-
* Default
|
|
614
|
+
* Default 600 000 (ten minutes).
|
|
615
615
|
*/
|
|
616
616
|
ariTtlMs?: number;
|
|
617
617
|
/** Names and addresses in Chinese (the records' own) or English where the record has it. Default `zh`. */
|
package/dist/huazhu/backend.d.ts
CHANGED
|
@@ -140,6 +140,14 @@ export declare const deadlineAt: (instant: number, tz: string, language?: "zh" |
|
|
|
140
140
|
export declare const movedSince: (shown: ShownQuote | undefined, q: Quote,
|
|
141
141
|
/** Hold the total to the one shown - not when a stay of it has since gone (it is in `failed`). */
|
|
142
142
|
whole?: boolean) => string | undefined;
|
|
143
|
+
/** How long prices and rooms left are kept for showing (a booking never uses them). */
|
|
144
|
+
export declare const ARI_TTL_MS: number;
|
|
145
|
+
/** How long what a hotel sells (room types x rates, sell days) is kept. */
|
|
146
|
+
export declare const PRODUCTS_TTL_MS: number;
|
|
147
|
+
/** A read of prices up to this old is shown when Huazhu will not answer (2001 / unreachable). */
|
|
148
|
+
export declare const ARI_STALE_MS: number;
|
|
149
|
+
/** After Huazhu answers 2001 流控限制, no more price calls for showing go out for this long. */
|
|
150
|
+
export declare const ARI_PAUSE_MS = 20000;
|
|
143
151
|
export declare const createHuazhuHotels: (opts: HuazhuHotelsOptions) => HotelBackend & {
|
|
144
152
|
capabilities: BackendCapabilities;
|
|
145
153
|
imageDomains(): string[];
|
|
@@ -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,EAEL,KAAK,aAAa,EAKnB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,QAAQ,EAAiC,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAGL,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAuBV,KAAK,EAML,UAAU,EAIX,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,YAAY,EAIjB,KAAK,UAAU,EAEf,KAAK,aAAa,EAGnB,MAAM,eAAe,CAAC;AAcvB,OAAO,EACL,KAAK,OAAO,EAUb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,YAAY,EAAmD,MAAM,aAAa,CAAC;AAkBjG,OAAO,EAQL,KAAK,WAAW,EAGhB,KAAK,WAAW,EAEhB,KAAK,OAAO,EAIb,MAAM,WAAW,CAAC;AAsBnB,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,gGAAgG;IAChG,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACnD,QAAQ,EAAE,IAAI,GAAG,IAAI,C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AM,KAAG,WAAW,EAK3E,CAAC;AAUF,oFAAoF;AACpF,eAAO,MAAM,WAAW,GAAI,QAAQ,WAAW,EAAE,EAAE,KAAK,MAAM,KAAG,WAAW,EAO3E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,IAAI,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;AAwBF,uFAAuF;AACvF,eAAO,MAAM,UAAU,QAAc,CAAC;AACtC,2EAA2E;AAC3E,eAAO,MAAM,eAAe,QAAgB,CAAC;AAC7C,iGAAiG;AACjG,eAAO,MAAM,YAAY,QAAc,CAAC;AACxC,4FAA4F;AAC5F,eAAO,MAAM,YAAY,QAAS,CAAC;AAUnC,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;CAk6I9B,CAAC"}
|
package/dist/huazhu/backend.js
CHANGED
|
@@ -41,6 +41,8 @@ export const HUAZHU_CAPABILITIES = {
|
|
|
41
41
|
codePrefix: 'HZ',
|
|
42
42
|
// A list without dates is tonight's, priced, at any size (robin 10-30, 11-18 at 88 hotels).
|
|
43
43
|
listsTonight: true,
|
|
44
|
+
// The hotel's own answer carries its phone, opening year and room count (0.77.1).
|
|
45
|
+
hotelFacts: true,
|
|
44
46
|
};
|
|
45
47
|
/** A phone number a desk could ring: at least six digits, nothing but digits and the usual separators. */
|
|
46
48
|
export const isPhone = (raw) => {
|
|
@@ -523,6 +525,14 @@ const DETAIL_FRESH_MS = 60_000;
|
|
|
523
525
|
const DETAIL_RETRY_MS = 2 * 60_000;
|
|
524
526
|
/** The background watch tries a booking again this soon after a read of it failed (never later than its usual interval). */
|
|
525
527
|
const WATCH_RETRY_MS = 30 * 60_000;
|
|
528
|
+
/** How long prices and rooms left are kept for showing (a booking never uses them). */
|
|
529
|
+
export const ARI_TTL_MS = 10 * 60_000;
|
|
530
|
+
/** How long what a hotel sells (room types x rates, sell days) is kept. */
|
|
531
|
+
export const PRODUCTS_TTL_MS = 6 * 3_600_000;
|
|
532
|
+
/** A read of prices up to this old is shown when Huazhu will not answer (2001 / unreachable). */
|
|
533
|
+
export const ARI_STALE_MS = 60 * 60_000;
|
|
534
|
+
/** After Huazhu answers 2001 流控限制, no more price calls for showing go out for this long. */
|
|
535
|
+
export const ARI_PAUSE_MS = 20_000;
|
|
526
536
|
/**
|
|
527
537
|
* The WHOLE background watch rests this long after a read it made failed
|
|
528
538
|
* (2026-10-21, 总线程): with Huazhu not answering, each 10-second pass tried
|
|
@@ -570,8 +580,13 @@ export const createHuazhuHotels = (opts) => {
|
|
|
570
580
|
const listed = (p) => p.res.ok ? p : p.shown ? { ...p, res: p.shown } : undefined;
|
|
571
581
|
const now = opts.now ?? (() => Date.now());
|
|
572
582
|
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
573
|
-
|
|
574
|
-
|
|
583
|
+
// ⚠️ SHOWING IS CACHED LONG, BOOKING IS NEVER (0.77.3, robin 11-19: Huazhu's
|
|
584
|
+
// production answered 2001 流控 after four calls). What a hotel sells (rooms
|
|
585
|
+
// x rates, days ahead) changes rarely: six hours. Prices and rooms left, for
|
|
586
|
+
// showing - tiles, the page, a comparison - ten minutes. A booking, and the
|
|
587
|
+
// review that feeds it, asks fresh (`fresh: true`) and never takes this.
|
|
588
|
+
const ariTtl = opts.ariTtlMs ?? ARI_TTL_MS;
|
|
589
|
+
const productsTtl = opts.productsTtlMs ?? PRODUCTS_TTL_MS;
|
|
575
590
|
const allowTags = new Set(opts.allowTags ?? []);
|
|
576
591
|
const view = {
|
|
577
592
|
language: opts.language,
|
|
@@ -774,6 +789,42 @@ export const createHuazhuHotels = (opts) => {
|
|
|
774
789
|
* booking's own fresh ask is not held back.
|
|
775
790
|
*/
|
|
776
791
|
const ariBackoff = new Map();
|
|
792
|
+
/**
|
|
793
|
+
* ⚠️ HUAZHU'S OWN FLOW CONTROL (0.77.3): 2001 with 「流控限制」 - production
|
|
794
|
+
* answered it after four calls 3.5 s apart, and a list tile said no price
|
|
795
|
+
* while the page a moment later had them. When it is answered, no price call
|
|
796
|
+
* for SHOWING goes out for `ARI_PAUSE_MS` (deployment-wide); what was read
|
|
797
|
+
* last is shown instead, if it is under an hour old. A booking's fresh ask is
|
|
798
|
+
* never held back, and never served from the old.
|
|
799
|
+
*/
|
|
800
|
+
let ariPausedUntil = 0;
|
|
801
|
+
const isFlowControl = (err) => err instanceof HuazhuRefusal &&
|
|
802
|
+
err.code === CODES.systemError &&
|
|
803
|
+
/流控/.test(`${err.detail} ${err.huazhuMessage}`);
|
|
804
|
+
/** A failure that is Huazhu not answering rightly, not a rule about this stay. */
|
|
805
|
+
const staleable = (err) => err instanceof HuazhuUnreachable ||
|
|
806
|
+
(err instanceof HuazhuRefusal &&
|
|
807
|
+
(err.code === CODES.systemError || err.code === CODES.rateLimited));
|
|
808
|
+
const pauseAri = () => {
|
|
809
|
+
if (now() < ariPausedUntil)
|
|
810
|
+
return;
|
|
811
|
+
ariPausedUntil = now() + ARI_PAUSE_MS;
|
|
812
|
+
console.error(`[huazhu] Huazhu answered 2001 流控限制: price calls for showing paused ${ARI_PAUSE_MS / 1000}s`);
|
|
813
|
+
};
|
|
814
|
+
/** The last read of `key`, when it is under an hour old - or nothing. */
|
|
815
|
+
const staleOf = (cache, key, err) => {
|
|
816
|
+
const hit = cache.get(key);
|
|
817
|
+
if (!hit || now() - hit.at >= ARI_STALE_MS)
|
|
818
|
+
return undefined;
|
|
819
|
+
const why = isFlowControl(err)
|
|
820
|
+
? '2001 流控'
|
|
821
|
+
: err instanceof HuazhuRefusal
|
|
822
|
+
? `${err.code}`
|
|
823
|
+
: 'no answer';
|
|
824
|
+
console.error(`[huazhu] served stale ARI after ${why} (${key}, ${Math.round((now() - hit.at) / 60_000)} min old)`);
|
|
825
|
+
return hit.value;
|
|
826
|
+
};
|
|
827
|
+
const pausedError = (path) => new HuazhuUnreachable(path, 'not sent - paused after Huazhu answered 2001 流控限制');
|
|
777
828
|
/** Every product's prices, rules and rooms left, one element per date from `start` to `end`. */
|
|
778
829
|
const ariFor = async (hotelId, start, end, fresh = false) => {
|
|
779
830
|
const key = `${hotelId}|${start}|${end}`;
|
|
@@ -786,6 +837,12 @@ export const createHuazhuHotels = (opts) => {
|
|
|
786
837
|
return hit.value;
|
|
787
838
|
throw new HuazhuRefusal(CODES.rateLimited, 'Too many requests', '', '/ari/daily/offers');
|
|
788
839
|
}
|
|
840
|
+
if (!fresh && now() < ariPausedUntil) {
|
|
841
|
+
const old = staleOf(ariCache, key, new HuazhuRefusal(CODES.systemError, '', '流控限制', ''));
|
|
842
|
+
if (old)
|
|
843
|
+
return old;
|
|
844
|
+
throw pausedError('/ari/daily/offers');
|
|
845
|
+
}
|
|
789
846
|
const ranges = ariRanges(start, end);
|
|
790
847
|
const parts = await Promise.all(ranges.map(async (r) => {
|
|
791
848
|
const [offers, inventory] = await Promise.all([
|
|
@@ -812,8 +869,16 @@ export const createHuazhuHotels = (opts) => {
|
|
|
812
869
|
const wait = Math.min((ariBackoff.get(hotelId)?.wait ?? 30_000) * 2, 10 * 60_000);
|
|
813
870
|
ariBackoff.set(hotelId, { until: now() + wait, wait });
|
|
814
871
|
}
|
|
872
|
+
if (isFlowControl(err))
|
|
873
|
+
pauseAri();
|
|
874
|
+
// A booking's fresh ask never takes an old read.
|
|
875
|
+
const old = !fresh && staleable(err) ? staleOf(ariCache, key, err) : undefined;
|
|
876
|
+
if (old)
|
|
877
|
+
return old;
|
|
815
878
|
throw err;
|
|
816
879
|
});
|
|
880
|
+
if (parts instanceof Map)
|
|
881
|
+
return parts;
|
|
817
882
|
ariBackoff.delete(hotelId);
|
|
818
883
|
const out = new Map();
|
|
819
884
|
const keys = new Set(parts.flatMap((p) => p.offers.map((o) => roomIdOf(o))));
|
|
@@ -908,7 +973,13 @@ export const createHuazhuHotels = (opts) => {
|
|
|
908
973
|
const hit = hourlyAriCache.get(key);
|
|
909
974
|
if (!fresh && hit && now() - hit.at < ariTtl)
|
|
910
975
|
return hit.value;
|
|
911
|
-
|
|
976
|
+
if (!fresh && now() < ariPausedUntil) {
|
|
977
|
+
const old = staleOf(hourlyAriCache, key, new HuazhuRefusal(CODES.systemError, '', '流控限制', ''));
|
|
978
|
+
if (old)
|
|
979
|
+
return old;
|
|
980
|
+
throw pausedError('/ari/daily/offers');
|
|
981
|
+
}
|
|
982
|
+
const got = await Promise.all([
|
|
912
983
|
client.offers(hotelId, date, date, undefined, 'HOUR').catch((err) => {
|
|
913
984
|
if (err instanceof HuazhuRefusal && [4206, 2008].includes(err.code))
|
|
914
985
|
return { dailyOffers: [] };
|
|
@@ -921,7 +992,17 @@ export const createHuazhuHotels = (opts) => {
|
|
|
921
992
|
};
|
|
922
993
|
throw err;
|
|
923
994
|
}),
|
|
924
|
-
])
|
|
995
|
+
]).catch((err) => {
|
|
996
|
+
if (isFlowControl(err))
|
|
997
|
+
pauseAri();
|
|
998
|
+
const old = !fresh && staleable(err) ? staleOf(hourlyAriCache, key, err) : undefined;
|
|
999
|
+
if (old)
|
|
1000
|
+
return old;
|
|
1001
|
+
throw err;
|
|
1002
|
+
});
|
|
1003
|
+
if (got instanceof Map)
|
|
1004
|
+
return got;
|
|
1005
|
+
const [offers, inventory] = got;
|
|
925
1006
|
const out = new Map();
|
|
926
1007
|
for (const offer of offers.dailyOffers ?? []) {
|
|
927
1008
|
const row = (inventory.dailyInventories ?? []).find((i) => roomIdOf(i) === roomIdOf(offer));
|
|
@@ -1492,7 +1573,8 @@ export const createHuazhuHotels = (opts) => {
|
|
|
1492
1573
|
};
|
|
1493
1574
|
};
|
|
1494
1575
|
const quote = async (trip) => {
|
|
1495
|
-
|
|
1576
|
+
// Fresh: this is the review a booking follows - never a ten-minute-old price.
|
|
1577
|
+
const { sold, ...q } = await quoteLines(trip, true);
|
|
1496
1578
|
void sold;
|
|
1497
1579
|
return q;
|
|
1498
1580
|
};
|