@tramvai/tinkoff-request-http-client-adapter 0.8.189 → 0.8.205
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/agent/createAgent.d.ts +4 -4
- package/lib/createTinkoffRequest.d.ts +7 -0
- package/lib/index.browser.js +4 -4
- package/lib/index.es.js +4 -4
- package/lib/index.js +4 -4
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { AgentOptions } from 'https';
|
|
3
|
-
|
|
2
|
+
import type { Agent, AgentOptions } from 'https';
|
|
3
|
+
export type { Agent, AgentOptions };
|
|
4
4
|
export declare const createAgent: (options?: AgentOptions) => {
|
|
5
|
-
http:
|
|
6
|
-
https:
|
|
5
|
+
http: Agent;
|
|
6
|
+
https: Agent;
|
|
7
7
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { ContextState, MakeRequest } from '@tinkoff/request-core';
|
|
2
3
|
import type { Options as CircuitBreakerOptions } from '@tinkoff/request-plugin-circuit-breaker';
|
|
3
4
|
import type { HttpClientBaseOptions } from '@tramvai/http-client';
|
|
4
5
|
import type { LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
6
|
+
import type { Agent } from './agent/createAgent';
|
|
7
|
+
export type { Agent };
|
|
5
8
|
export declare type RequestValidator = {
|
|
6
9
|
(state: ContextState): any;
|
|
7
10
|
};
|
|
@@ -17,5 +20,9 @@ export interface TinkoffRequestOptions extends HttpClientBaseOptions {
|
|
|
17
20
|
errorValidator?: RequestValidator;
|
|
18
21
|
errorModificator?: RequestValidator;
|
|
19
22
|
circuitBreakerOptions?: CircuitBreakerOptions;
|
|
23
|
+
agent?: {
|
|
24
|
+
http: Agent;
|
|
25
|
+
https: Agent;
|
|
26
|
+
};
|
|
20
27
|
}
|
|
21
28
|
export declare function createTinkoffRequest(options: TinkoffRequestOptions): MakeRequest;
|
package/lib/index.browser.js
CHANGED
|
@@ -11,9 +11,9 @@ import compose from '@tinkoff/utils/function/compose';
|
|
|
11
11
|
|
|
12
12
|
const createAgent = () => { };
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const defaultAgent = createAgent();
|
|
15
15
|
function createTinkoffRequest(options) {
|
|
16
|
-
const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, ...defaults } = options;
|
|
16
|
+
const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, agent, ...defaults } = options;
|
|
17
17
|
const log = logger && logger(`${name}:initialization`);
|
|
18
18
|
const plugins = [];
|
|
19
19
|
plugins.push({
|
|
@@ -94,7 +94,7 @@ function createTinkoffRequest(options) {
|
|
|
94
94
|
allowFallback: true,
|
|
95
95
|
}));
|
|
96
96
|
}
|
|
97
|
-
plugins.push(http({ agent }));
|
|
97
|
+
plugins.push(http({ agent: agent || defaultAgent }));
|
|
98
98
|
const makeRequest = request(plugins);
|
|
99
99
|
return makeRequest;
|
|
100
100
|
}
|
|
@@ -227,7 +227,7 @@ class HttpClientAdapter {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
function createAdapter(options) {
|
|
230
|
-
const { logger, name, disableCache, createCache, cacheTime, defaultTimeout, validator, errorValidator, errorModificator, modifyRequest = (req) => req, modifyResponse = (res) => res, modifyError = (err) => err, ...httpClientOptions } = options;
|
|
230
|
+
const { logger, name, disableCache, createCache, cacheTime, defaultTimeout, validator, errorValidator, errorModificator, agent, modifyRequest = (req) => req, modifyResponse = (res) => res, modifyError = (err) => err, ...httpClientOptions } = options;
|
|
231
231
|
const tinkoffRequest = createTinkoffRequest(options);
|
|
232
232
|
const httpClientAdapter = new HttpClientAdapter({
|
|
233
233
|
options: {
|
package/lib/index.es.js
CHANGED
|
@@ -21,9 +21,9 @@ const createAgent = (options = {
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const defaultAgent = createAgent();
|
|
25
25
|
function createTinkoffRequest(options) {
|
|
26
|
-
const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, ...defaults } = options;
|
|
26
|
+
const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, agent, ...defaults } = options;
|
|
27
27
|
const log = logger && logger(`${name}:initialization`);
|
|
28
28
|
const plugins = [];
|
|
29
29
|
plugins.push({
|
|
@@ -104,7 +104,7 @@ function createTinkoffRequest(options) {
|
|
|
104
104
|
allowFallback: true,
|
|
105
105
|
}));
|
|
106
106
|
}
|
|
107
|
-
plugins.push(http$1({ agent }));
|
|
107
|
+
plugins.push(http$1({ agent: agent || defaultAgent }));
|
|
108
108
|
const makeRequest = request(plugins);
|
|
109
109
|
return makeRequest;
|
|
110
110
|
}
|
|
@@ -237,7 +237,7 @@ class HttpClientAdapter {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
function createAdapter(options) {
|
|
240
|
-
const { logger, name, disableCache, createCache, cacheTime, defaultTimeout, validator, errorValidator, errorModificator, modifyRequest = (req) => req, modifyResponse = (res) => res, modifyError = (err) => err, ...httpClientOptions } = options;
|
|
240
|
+
const { logger, name, disableCache, createCache, cacheTime, defaultTimeout, validator, errorValidator, errorModificator, agent, modifyRequest = (req) => req, modifyResponse = (res) => res, modifyError = (err) => err, ...httpClientOptions } = options;
|
|
241
241
|
const tinkoffRequest = createTinkoffRequest(options);
|
|
242
242
|
const httpClientAdapter = new HttpClientAdapter({
|
|
243
243
|
options: {
|
package/lib/index.js
CHANGED
|
@@ -40,9 +40,9 @@ const createAgent = (options = {
|
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const defaultAgent = createAgent();
|
|
44
44
|
function createTinkoffRequest(options) {
|
|
45
|
-
const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, ...defaults } = options;
|
|
45
|
+
const { logger, name, disableCache, enableCircuitBreaker, createCache, cacheTime = 30000, defaultTimeout, validator, errorValidator, errorModificator, circuitBreakerOptions = {}, agent, ...defaults } = options;
|
|
46
46
|
const log = logger && logger(`${name}:initialization`);
|
|
47
47
|
const plugins = [];
|
|
48
48
|
plugins.push({
|
|
@@ -123,7 +123,7 @@ function createTinkoffRequest(options) {
|
|
|
123
123
|
allowFallback: true,
|
|
124
124
|
}));
|
|
125
125
|
}
|
|
126
|
-
plugins.push(http__default$1["default"]({ agent }));
|
|
126
|
+
plugins.push(http__default$1["default"]({ agent: agent || defaultAgent }));
|
|
127
127
|
const makeRequest = request__default["default"](plugins);
|
|
128
128
|
return makeRequest;
|
|
129
129
|
}
|
|
@@ -256,7 +256,7 @@ class HttpClientAdapter {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
function createAdapter(options) {
|
|
259
|
-
const { logger, name, disableCache, createCache, cacheTime, defaultTimeout, validator, errorValidator, errorModificator, modifyRequest = (req) => req, modifyResponse = (res) => res, modifyError = (err) => err, ...httpClientOptions } = options;
|
|
259
|
+
const { logger, name, disableCache, createCache, cacheTime, defaultTimeout, validator, errorValidator, errorModificator, agent, modifyRequest = (req) => req, modifyResponse = (res) => res, modifyError = (err) => err, ...httpClientOptions } = options;
|
|
260
260
|
const tinkoffRequest = createTinkoffRequest(options);
|
|
261
261
|
const httpClientAdapter = new HttpClientAdapter({
|
|
262
262
|
options: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/tinkoff-request-http-client-adapter",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.205",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@tinkoff/request-plugin-validate": "^0.8.8",
|
|
32
32
|
"@tinkoff/utils": "^2.1.2",
|
|
33
33
|
"@tramvai/http-client": "0.1.23",
|
|
34
|
-
"@tramvai/tokens-common": "1.
|
|
34
|
+
"@tramvai/tokens-common": "1.46.5",
|
|
35
35
|
"tslib": "^2.0.3"
|
|
36
36
|
},
|
|
37
37
|
"sideEffects": false,
|