@renaissancerentals/renaissance-component 13.0.14 → 13.0.16
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/lib/asset/service/AssetService.d.ts +25 -2
- package/lib/asset/service/ImageWidth.d.ts +6 -0
- package/lib/index.cjs.js +40 -40
- package/lib/index.d.ts +1 -1
- package/lib/index.es.js +7531 -7375
- package/lib/index.umd.js +39 -39
- package/lib/service/Api.d.ts +32 -3
- package/package.json +1 -1
package/lib/service/Api.d.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* The sites read their data from one or more hosts that serve the same API (REACT_APP_DATA_BASE_URLS, comma
|
|
4
|
+
* separated). The client is built to survive one of them being down:
|
|
5
|
+
* - a tab sticks to one host (a random one to start with, so load spreads across visitors), which keeps the
|
|
6
|
+
* connection warm; it does not alternate per request;
|
|
7
|
+
* - a GET that fails on the host (network error, timeout, 429 or 5xx) is retried once on the next host;
|
|
8
|
+
* - a host that fails twice in a row is skipped for a minute (circuit breaker), remembered for the tab;
|
|
9
|
+
* - POST/PUT/PATCH/DELETE are never replayed on another host: a failed contact or application request may have
|
|
10
|
+
* reached the server, and replaying it could send the message twice;
|
|
11
|
+
* - identical GETs for listing data are answered once: concurrent callers share one request and the answer is
|
|
12
|
+
* kept for a short time (see the cache below).
|
|
13
|
+
*/
|
|
2
14
|
export declare const REACT_APP_DATA_BASE_URLS: string[];
|
|
15
|
+
export declare const GET_TIMEOUT_MS = 8000;
|
|
16
|
+
export declare const clearApiCache: () => void;
|
|
17
|
+
/** Starts from the state this tab remembers (or a random primary host). Mainly for tests and first load. */
|
|
18
|
+
export declare const resetApiState: () => void;
|
|
19
|
+
/** The host to use now. Reading it never changes anything, so calling it twice gives the same answer. */
|
|
3
20
|
export declare const getBaseUrl: () => string;
|
|
4
21
|
export declare const DEFAULT_IMAGE_URL: string;
|
|
5
|
-
declare const
|
|
6
|
-
|
|
7
|
-
|
|
22
|
+
declare const Api: import("axios").AxiosInstance;
|
|
23
|
+
/**
|
|
24
|
+
* Response cache for GETs. Several components ask for the same listing (a property, its floorplans, its FAQs) while
|
|
25
|
+
* a page is built, and visitors move back and forth between pages; the answer rarely changes within seconds.
|
|
26
|
+
* - only paths that carry listing data are cached (see CACHEABLE); sublets, which change as people post, are not;
|
|
27
|
+
* - the key is the path, not the host, because all hosts serve the same data;
|
|
28
|
+
* - concurrent identical requests share one request, failures are never kept;
|
|
29
|
+
* - every caller gets its own copy of the data, because components sort and edit the arrays they receive;
|
|
30
|
+
* - any successful write empties the cache;
|
|
31
|
+
* - a request with "Cache-Control: no-cache" skips the cache and refreshes it.
|
|
32
|
+
*/
|
|
33
|
+
/** How long a GET answer is reused, in milliseconds. 0 switches the cache off. */
|
|
34
|
+
export declare const setApiCacheTtl: (ms: number) => void;
|
|
35
|
+
export default Api;
|
|
36
|
+
export declare const get: (url: string) => Promise<AxiosResponse>;
|