@algolia/client-common 5.0.0-alpha.53 → 5.0.0-alpha.55
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/client-common.cjs.js +77 -77
- package/dist/client-common.esm.node.js +77 -77
- package/dist/index.d.ts +9 -9
- package/dist/src/cache/createBrowserLocalStorageCache.d.ts +2 -2
- package/dist/src/cache/createFallbackableCache.d.ts +2 -2
- package/dist/src/cache/createMemoryCache.d.ts +2 -2
- package/dist/src/cache/createNullCache.d.ts +2 -2
- package/dist/src/cache/index.d.ts +4 -4
- package/dist/src/constants.d.ts +6 -6
- package/dist/src/createAlgoliaAgent.d.ts +2 -2
- package/dist/src/createAuth.d.ts +5 -5
- package/dist/src/createEchoRequester.d.ts +6 -6
- package/dist/src/createIterablePromise.d.ts +12 -12
- package/dist/src/getAlgoliaAgent.d.ts +7 -7
- package/dist/src/transporter/createStatefulHost.d.ts +2 -2
- package/dist/src/transporter/createTransporter.d.ts +2 -2
- package/dist/src/transporter/errors.d.ts +37 -37
- package/dist/src/transporter/helpers.d.ts +8 -8
- package/dist/src/transporter/index.d.ts +6 -6
- package/dist/src/transporter/responses.d.ts +4 -4
- package/dist/src/transporter/stackTrace.d.ts +3 -3
- package/dist/src/types/cache.d.ts +46 -46
- package/dist/src/types/createClient.d.ts +11 -11
- package/dist/src/types/createIterablePromise.d.ts +35 -35
- package/dist/src/types/host.d.ts +32 -32
- package/dist/src/types/index.d.ts +6 -6
- package/dist/src/types/requester.d.ts +65 -65
- package/dist/src/types/transporter.d.ts +127 -127
- package/package.json +6 -6
- package/src/createEchoRequester.ts +1 -1
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
import type { Cache } from './cache';
|
|
2
|
-
import type { Host } from './host';
|
|
3
|
-
import type { Request, Requester, EndRequest, Response } from './requester';
|
|
4
|
-
export type Headers = Record<string, string>;
|
|
5
|
-
export type QueryParameters = Record<string, any>;
|
|
6
|
-
export type RequestOptions = Pick<Request, 'cacheable'> & {
|
|
7
|
-
/**
|
|
8
|
-
* Custom timeout for the request. Note that, in normal situations
|
|
9
|
-
* the given timeout will be applied. But the transporter layer may
|
|
10
|
-
* increase this timeout if there is need for it.
|
|
11
|
-
*/
|
|
12
|
-
timeout?: number;
|
|
13
|
-
/**
|
|
14
|
-
* Custom headers for the request. This headers are
|
|
15
|
-
* going to be merged the transporter headers.
|
|
16
|
-
*/
|
|
17
|
-
headers?: Headers;
|
|
18
|
-
/**
|
|
19
|
-
* Custom query parameters for the request. This query parameters are
|
|
20
|
-
* going to be merged the transporter query parameters.
|
|
21
|
-
*/
|
|
22
|
-
queryParameters?: QueryParameters;
|
|
23
|
-
/**
|
|
24
|
-
* Custom data for the request. This data is
|
|
25
|
-
* going to be merged the transporter data.
|
|
26
|
-
*/
|
|
27
|
-
data?: Array<Record<string, any>> | Record<string, any>;
|
|
28
|
-
};
|
|
29
|
-
export type StackFrame = {
|
|
30
|
-
request: EndRequest;
|
|
31
|
-
response: Response;
|
|
32
|
-
host: Host;
|
|
33
|
-
triesLeft: number;
|
|
34
|
-
};
|
|
35
|
-
export type AlgoliaAgentOptions = {
|
|
36
|
-
/**
|
|
37
|
-
* The segment. Usually the integration name.
|
|
38
|
-
*/
|
|
39
|
-
segment: string;
|
|
40
|
-
/**
|
|
41
|
-
* The version. Usually the integration version.
|
|
42
|
-
*/
|
|
43
|
-
version?: string;
|
|
44
|
-
};
|
|
45
|
-
export type AlgoliaAgent = {
|
|
46
|
-
/**
|
|
47
|
-
* The raw value of the user agent.
|
|
48
|
-
*/
|
|
49
|
-
value: string;
|
|
50
|
-
/**
|
|
51
|
-
* Mutates the current user agent adding the given user agent options.
|
|
52
|
-
*/
|
|
53
|
-
add: (options: AlgoliaAgentOptions) => AlgoliaAgent;
|
|
54
|
-
};
|
|
55
|
-
export type Timeouts = {
|
|
56
|
-
/**
|
|
57
|
-
* Timeout in milliseconds before the connection is established.
|
|
58
|
-
*/
|
|
59
|
-
connect: number;
|
|
60
|
-
/**
|
|
61
|
-
* Timeout in milliseconds before reading the response on a read request.
|
|
62
|
-
*/
|
|
63
|
-
read: number;
|
|
64
|
-
/**
|
|
65
|
-
* Timeout in milliseconds before reading the response on a write request.
|
|
66
|
-
*/
|
|
67
|
-
write: number;
|
|
68
|
-
};
|
|
69
|
-
export type TransporterOptions = {
|
|
70
|
-
/**
|
|
71
|
-
* The cache of the hosts. Usually used to persist
|
|
72
|
-
* the state of the host when its down.
|
|
73
|
-
*/
|
|
74
|
-
hostsCache: Cache;
|
|
75
|
-
/**
|
|
76
|
-
* The underlying requester used. Should differ
|
|
77
|
-
* depending of the environment where the client
|
|
78
|
-
* will be used.
|
|
79
|
-
*/
|
|
80
|
-
requester: Requester;
|
|
81
|
-
/**
|
|
82
|
-
* The cache of the requests. When requests are
|
|
83
|
-
* `cacheable`, the returned promised persists
|
|
84
|
-
* in this cache to shared in similar requests
|
|
85
|
-
* before being resolved.
|
|
86
|
-
*/
|
|
87
|
-
requestsCache: Cache;
|
|
88
|
-
/**
|
|
89
|
-
* The cache of the responses. When requests are
|
|
90
|
-
* `cacheable`, the returned responses persists
|
|
91
|
-
* in this cache to shared in similar requests.
|
|
92
|
-
*/
|
|
93
|
-
responsesCache: Cache;
|
|
94
|
-
/**
|
|
95
|
-
* The timeouts used by the requester. The transporter
|
|
96
|
-
* layer may increase this timeouts as defined on the
|
|
97
|
-
* retry strategy.
|
|
98
|
-
*/
|
|
99
|
-
timeouts: Timeouts;
|
|
100
|
-
/**
|
|
101
|
-
* The hosts used by the requester.
|
|
102
|
-
*/
|
|
103
|
-
hosts: Host[];
|
|
104
|
-
/**
|
|
105
|
-
* The headers used by the requester. The transporter
|
|
106
|
-
* layer may add some extra headers during the request
|
|
107
|
-
* for the user agent, and others.
|
|
108
|
-
*/
|
|
109
|
-
baseHeaders: Headers;
|
|
110
|
-
/**
|
|
111
|
-
* The query parameters used by the requester. The transporter
|
|
112
|
-
* layer may add some extra headers during the request
|
|
113
|
-
* for the user agent, and others.
|
|
114
|
-
*/
|
|
115
|
-
baseQueryParameters: QueryParameters;
|
|
116
|
-
/**
|
|
117
|
-
* The user agent used. Sent on query parameters.
|
|
118
|
-
*/
|
|
119
|
-
algoliaAgent: AlgoliaAgent;
|
|
120
|
-
};
|
|
121
|
-
export type Transporter = TransporterOptions & {
|
|
122
|
-
/**
|
|
123
|
-
* Performs a request.
|
|
124
|
-
* The `baseRequest` and `baseRequestOptions` will be merged accordingly.
|
|
125
|
-
*/
|
|
126
|
-
request: <TResponse>(baseRequest: Request, baseRequestOptions?: RequestOptions) => Promise<TResponse>;
|
|
127
|
-
};
|
|
1
|
+
import type { Cache } from './cache';
|
|
2
|
+
import type { Host } from './host';
|
|
3
|
+
import type { Request, Requester, EndRequest, Response } from './requester';
|
|
4
|
+
export type Headers = Record<string, string>;
|
|
5
|
+
export type QueryParameters = Record<string, any>;
|
|
6
|
+
export type RequestOptions = Pick<Request, 'cacheable'> & {
|
|
7
|
+
/**
|
|
8
|
+
* Custom timeout for the request. Note that, in normal situations
|
|
9
|
+
* the given timeout will be applied. But the transporter layer may
|
|
10
|
+
* increase this timeout if there is need for it.
|
|
11
|
+
*/
|
|
12
|
+
timeout?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Custom headers for the request. This headers are
|
|
15
|
+
* going to be merged the transporter headers.
|
|
16
|
+
*/
|
|
17
|
+
headers?: Headers;
|
|
18
|
+
/**
|
|
19
|
+
* Custom query parameters for the request. This query parameters are
|
|
20
|
+
* going to be merged the transporter query parameters.
|
|
21
|
+
*/
|
|
22
|
+
queryParameters?: QueryParameters;
|
|
23
|
+
/**
|
|
24
|
+
* Custom data for the request. This data is
|
|
25
|
+
* going to be merged the transporter data.
|
|
26
|
+
*/
|
|
27
|
+
data?: Array<Record<string, any>> | Record<string, any>;
|
|
28
|
+
};
|
|
29
|
+
export type StackFrame = {
|
|
30
|
+
request: EndRequest;
|
|
31
|
+
response: Response;
|
|
32
|
+
host: Host;
|
|
33
|
+
triesLeft: number;
|
|
34
|
+
};
|
|
35
|
+
export type AlgoliaAgentOptions = {
|
|
36
|
+
/**
|
|
37
|
+
* The segment. Usually the integration name.
|
|
38
|
+
*/
|
|
39
|
+
segment: string;
|
|
40
|
+
/**
|
|
41
|
+
* The version. Usually the integration version.
|
|
42
|
+
*/
|
|
43
|
+
version?: string;
|
|
44
|
+
};
|
|
45
|
+
export type AlgoliaAgent = {
|
|
46
|
+
/**
|
|
47
|
+
* The raw value of the user agent.
|
|
48
|
+
*/
|
|
49
|
+
value: string;
|
|
50
|
+
/**
|
|
51
|
+
* Mutates the current user agent adding the given user agent options.
|
|
52
|
+
*/
|
|
53
|
+
add: (options: AlgoliaAgentOptions) => AlgoliaAgent;
|
|
54
|
+
};
|
|
55
|
+
export type Timeouts = {
|
|
56
|
+
/**
|
|
57
|
+
* Timeout in milliseconds before the connection is established.
|
|
58
|
+
*/
|
|
59
|
+
connect: number;
|
|
60
|
+
/**
|
|
61
|
+
* Timeout in milliseconds before reading the response on a read request.
|
|
62
|
+
*/
|
|
63
|
+
read: number;
|
|
64
|
+
/**
|
|
65
|
+
* Timeout in milliseconds before reading the response on a write request.
|
|
66
|
+
*/
|
|
67
|
+
write: number;
|
|
68
|
+
};
|
|
69
|
+
export type TransporterOptions = {
|
|
70
|
+
/**
|
|
71
|
+
* The cache of the hosts. Usually used to persist
|
|
72
|
+
* the state of the host when its down.
|
|
73
|
+
*/
|
|
74
|
+
hostsCache: Cache;
|
|
75
|
+
/**
|
|
76
|
+
* The underlying requester used. Should differ
|
|
77
|
+
* depending of the environment where the client
|
|
78
|
+
* will be used.
|
|
79
|
+
*/
|
|
80
|
+
requester: Requester;
|
|
81
|
+
/**
|
|
82
|
+
* The cache of the requests. When requests are
|
|
83
|
+
* `cacheable`, the returned promised persists
|
|
84
|
+
* in this cache to shared in similar requests
|
|
85
|
+
* before being resolved.
|
|
86
|
+
*/
|
|
87
|
+
requestsCache: Cache;
|
|
88
|
+
/**
|
|
89
|
+
* The cache of the responses. When requests are
|
|
90
|
+
* `cacheable`, the returned responses persists
|
|
91
|
+
* in this cache to shared in similar requests.
|
|
92
|
+
*/
|
|
93
|
+
responsesCache: Cache;
|
|
94
|
+
/**
|
|
95
|
+
* The timeouts used by the requester. The transporter
|
|
96
|
+
* layer may increase this timeouts as defined on the
|
|
97
|
+
* retry strategy.
|
|
98
|
+
*/
|
|
99
|
+
timeouts: Timeouts;
|
|
100
|
+
/**
|
|
101
|
+
* The hosts used by the requester.
|
|
102
|
+
*/
|
|
103
|
+
hosts: Host[];
|
|
104
|
+
/**
|
|
105
|
+
* The headers used by the requester. The transporter
|
|
106
|
+
* layer may add some extra headers during the request
|
|
107
|
+
* for the user agent, and others.
|
|
108
|
+
*/
|
|
109
|
+
baseHeaders: Headers;
|
|
110
|
+
/**
|
|
111
|
+
* The query parameters used by the requester. The transporter
|
|
112
|
+
* layer may add some extra headers during the request
|
|
113
|
+
* for the user agent, and others.
|
|
114
|
+
*/
|
|
115
|
+
baseQueryParameters: QueryParameters;
|
|
116
|
+
/**
|
|
117
|
+
* The user agent used. Sent on query parameters.
|
|
118
|
+
*/
|
|
119
|
+
algoliaAgent: AlgoliaAgent;
|
|
120
|
+
};
|
|
121
|
+
export type Transporter = TransporterOptions & {
|
|
122
|
+
/**
|
|
123
|
+
* Performs a request.
|
|
124
|
+
* The `baseRequest` and `baseRequestOptions` will be merged accordingly.
|
|
125
|
+
*/
|
|
126
|
+
request: <TResponse>(baseRequest: Request, baseRequestOptions?: RequestOptions) => Promise<TResponse>;
|
|
127
|
+
};
|
|
128
128
|
//# sourceMappingURL=transporter.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algolia/client-common",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.55",
|
|
4
4
|
"description": "Common package for the Algolia JavaScript API client.",
|
|
5
5
|
"repository": "algolia/algoliasearch-client-javascript",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"test": "jest"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@types/jest": "29.
|
|
23
|
-
"@types/node": "18.
|
|
24
|
-
"jest": "29.
|
|
25
|
-
"jest-environment-jsdom": "29.
|
|
22
|
+
"@types/jest": "29.5.0",
|
|
23
|
+
"@types/node": "18.15.11",
|
|
24
|
+
"jest": "29.5.0",
|
|
25
|
+
"jest-environment-jsdom": "29.5.0",
|
|
26
26
|
"ts-jest": "29.0.5",
|
|
27
|
-
"typescript": "
|
|
27
|
+
"typescript": "5.0.3"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">= 14.0.0"
|
|
@@ -11,7 +11,7 @@ function getUrlParams({
|
|
|
11
11
|
pathname,
|
|
12
12
|
}: URL): Pick<EchoResponse, 'algoliaAgent' | 'host' | 'path' | 'searchParams'> {
|
|
13
13
|
const algoliaAgent = urlSearchParams.get('x-algolia-agent') || '';
|
|
14
|
-
const searchParams = {};
|
|
14
|
+
const searchParams: Record<string, string> = {};
|
|
15
15
|
|
|
16
16
|
for (const [k, v] of urlSearchParams) {
|
|
17
17
|
if (k === 'x-algolia-agent') {
|