@tramvai/module-http-client 1.41.2 → 1.46.5
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/httpClient/httpClientFactory.d.ts +3 -2
- package/lib/index.browser.js +9 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.es.js +9 -2
- package/lib/index.js +19 -1
- package/package.json +11 -11
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { MakeRequest } from '@tinkoff/request-core';
|
|
2
2
|
import type { APP_INFO_TOKEN } from '@tramvai/core';
|
|
3
|
-
import type { API_CLIENT_PASS_HEADERS, HTTP_CLIENT_FACTORY } from '@tramvai/tokens-http-client';
|
|
3
|
+
import type { API_CLIENT_PASS_HEADERS, HTTP_CLIENT_AGENT, HTTP_CLIENT_FACTORY } from '@tramvai/tokens-http-client';
|
|
4
4
|
import type { LOGGER_TOKEN, CREATE_CACHE_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN } from '@tramvai/tokens-common';
|
|
5
|
-
export declare const httpClientFactory: ({ logger, envManager, appInfo, requestManager, headersList, createCache, tinkoffRequestRegistry, }: {
|
|
5
|
+
export declare const httpClientFactory: ({ logger, envManager, appInfo, requestManager, headersList, createCache, tinkoffRequestRegistry, agent, }: {
|
|
6
6
|
logger: typeof LOGGER_TOKEN;
|
|
7
7
|
envManager: typeof ENV_MANAGER_TOKEN;
|
|
8
8
|
appInfo: typeof APP_INFO_TOKEN;
|
|
@@ -10,4 +10,5 @@ export declare const httpClientFactory: ({ logger, envManager, appInfo, requestM
|
|
|
10
10
|
headersList?: typeof API_CLIENT_PASS_HEADERS;
|
|
11
11
|
createCache?: typeof CREATE_CACHE_TOKEN;
|
|
12
12
|
tinkoffRequestRegistry: Map<string, MakeRequest>;
|
|
13
|
+
agent?: typeof HTTP_CLIENT_AGENT;
|
|
13
14
|
}) => typeof HTTP_CLIENT_FACTORY;
|
package/lib/index.browser.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { createToken } from '@tinkoff/dippy';
|
|
3
3
|
import { Module, provide, Scope, APP_INFO_TOKEN } from '@tramvai/core';
|
|
4
|
-
import { PAPI_SERVICE, HTTP_CLIENT_FACTORY, API_CLIENT_PASS_HEADERS, HTTP_CLIENT } from '@tramvai/tokens-http-client';
|
|
4
|
+
import { PAPI_SERVICE, HTTP_CLIENT_FACTORY, API_CLIENT_PASS_HEADERS, HTTP_CLIENT_AGENT, HTTP_CLIENT } from '@tramvai/tokens-http-client';
|
|
5
|
+
export * from '@tramvai/tokens-http-client';
|
|
5
6
|
import { LOGGER_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN, ENV_USED_TOKEN, CREATE_CACHE_TOKEN } from '@tramvai/tokens-common';
|
|
6
7
|
import isNil from '@tinkoff/utils/is/nil';
|
|
7
8
|
import omit from '@tinkoff/utils/object/omit';
|
|
@@ -10,6 +11,7 @@ import { mergeOptions, createTinkoffRequest, HttpClientAdapter } from '@tramvai/
|
|
|
10
11
|
import { SERVER_MODULE_PAPI_PUBLIC_URL } from '@tramvai/tokens-server';
|
|
11
12
|
import prop from '@tinkoff/utils/object/prop';
|
|
12
13
|
import { ApiService } from '@tramvai/http-client';
|
|
14
|
+
export * from '@tramvai/http-client';
|
|
13
15
|
|
|
14
16
|
const fillHeaders = (deps) => (params) => {
|
|
15
17
|
return params;
|
|
@@ -55,7 +57,7 @@ const environmentDependentOptions = typeof window === 'undefined'
|
|
|
55
57
|
: {
|
|
56
58
|
defaultTimeout: 30000,
|
|
57
59
|
};
|
|
58
|
-
const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, tinkoffRequestRegistry, }) => {
|
|
60
|
+
const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, tinkoffRequestRegistry, agent, }) => {
|
|
59
61
|
return (options) => {
|
|
60
62
|
if (!options.name) {
|
|
61
63
|
throw Error(`Необходимо передать уникальное поле "name" для экземпляра HTTP клиента!`);
|
|
@@ -64,6 +66,7 @@ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, header
|
|
|
64
66
|
const forceDisabledCircuitBreaker = envManager.get('HTTP_CLIENT_CIRCUIT_BREAKER_DISABLED');
|
|
65
67
|
const adapterOptions = mergeOptions({
|
|
66
68
|
logger,
|
|
69
|
+
agent,
|
|
67
70
|
method: 'GET',
|
|
68
71
|
createCache: createCache
|
|
69
72
|
? (cacheOptions) => createCache('memory', cacheOptions)
|
|
@@ -189,6 +192,10 @@ HttpClientModule = __decorate([
|
|
|
189
192
|
token: API_CLIENT_PASS_HEADERS,
|
|
190
193
|
optional: true,
|
|
191
194
|
},
|
|
195
|
+
agent: {
|
|
196
|
+
token: HTTP_CLIENT_AGENT,
|
|
197
|
+
optional: true,
|
|
198
|
+
},
|
|
192
199
|
},
|
|
193
200
|
}),
|
|
194
201
|
provide({
|
package/lib/index.d.ts
CHANGED
|
@@ -3,3 +3,5 @@ export { httpClientFactory } from './httpClient/httpClientFactory';
|
|
|
3
3
|
export { PapiService } from './papiClientModule';
|
|
4
4
|
export { fillHeaderIp, fillHeaders } from './utils/fillHeaders';
|
|
5
5
|
export { formatError } from './utils/errors';
|
|
6
|
+
export * from '@tramvai/tokens-http-client';
|
|
7
|
+
export * from '@tramvai/http-client';
|
package/lib/index.es.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { createChildContainer, createToken } from '@tinkoff/dippy';
|
|
3
3
|
import { Module, provide, Scope, DI_TOKEN, APP_INFO_TOKEN } from '@tramvai/core';
|
|
4
|
-
import { PAPI_SERVICE, HTTP_CLIENT_FACTORY, API_CLIENT_PASS_HEADERS, HTTP_CLIENT } from '@tramvai/tokens-http-client';
|
|
4
|
+
import { PAPI_SERVICE, HTTP_CLIENT_FACTORY, API_CLIENT_PASS_HEADERS, HTTP_CLIENT_AGENT, HTTP_CLIENT } from '@tramvai/tokens-http-client';
|
|
5
|
+
export * from '@tramvai/tokens-http-client';
|
|
5
6
|
import { LOGGER_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN, ENV_USED_TOKEN, CREATE_CACHE_TOKEN } from '@tramvai/tokens-common';
|
|
6
7
|
import isNil from '@tinkoff/utils/is/nil';
|
|
7
8
|
import omit from '@tinkoff/utils/object/omit';
|
|
@@ -14,6 +15,7 @@ import { SERVER_MODULE_PAPI_PUBLIC_ROUTE } from '@tramvai/tokens-server';
|
|
|
14
15
|
import find from '@tinkoff/utils/array/find';
|
|
15
16
|
import { getPapiParameters } from '@tramvai/papi';
|
|
16
17
|
import { REQUEST, RESPONSE } from '@tramvai/module-common';
|
|
18
|
+
export * from '@tramvai/http-client';
|
|
17
19
|
|
|
18
20
|
const fillHeaderIp = ({ requestManager, }) => {
|
|
19
21
|
if (!requestManager) {
|
|
@@ -84,7 +86,7 @@ const environmentDependentOptions = typeof window === 'undefined'
|
|
|
84
86
|
: {
|
|
85
87
|
defaultTimeout: 30000,
|
|
86
88
|
};
|
|
87
|
-
const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, tinkoffRequestRegistry, }) => {
|
|
89
|
+
const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, tinkoffRequestRegistry, agent, }) => {
|
|
88
90
|
return (options) => {
|
|
89
91
|
if (!options.name) {
|
|
90
92
|
throw Error(`Необходимо передать уникальное поле "name" для экземпляра HTTP клиента!`);
|
|
@@ -93,6 +95,7 @@ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, header
|
|
|
93
95
|
const forceDisabledCircuitBreaker = envManager.get('HTTP_CLIENT_CIRCUIT_BREAKER_DISABLED');
|
|
94
96
|
const adapterOptions = mergeOptions({
|
|
95
97
|
logger,
|
|
98
|
+
agent,
|
|
96
99
|
method: 'GET',
|
|
97
100
|
createCache: createCache
|
|
98
101
|
? (cacheOptions) => createCache('memory', cacheOptions)
|
|
@@ -268,6 +271,10 @@ HttpClientModule = __decorate([
|
|
|
268
271
|
token: API_CLIENT_PASS_HEADERS,
|
|
269
272
|
optional: true,
|
|
270
273
|
},
|
|
274
|
+
agent: {
|
|
275
|
+
token: HTTP_CLIENT_AGENT,
|
|
276
|
+
optional: true,
|
|
277
|
+
},
|
|
271
278
|
},
|
|
272
279
|
}),
|
|
273
280
|
provide({
|
package/lib/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var tokensServer = require('@tramvai/tokens-server');
|
|
|
18
18
|
var find = require('@tinkoff/utils/array/find');
|
|
19
19
|
var papi = require('@tramvai/papi');
|
|
20
20
|
var moduleCommon = require('@tramvai/module-common');
|
|
21
|
+
var httpClient = require('@tramvai/http-client');
|
|
21
22
|
|
|
22
23
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
24
|
|
|
@@ -98,7 +99,7 @@ const environmentDependentOptions = typeof window === 'undefined'
|
|
|
98
99
|
: {
|
|
99
100
|
defaultTimeout: 30000,
|
|
100
101
|
};
|
|
101
|
-
const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, tinkoffRequestRegistry, }) => {
|
|
102
|
+
const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, tinkoffRequestRegistry, agent, }) => {
|
|
102
103
|
return (options) => {
|
|
103
104
|
if (!options.name) {
|
|
104
105
|
throw Error(`Необходимо передать уникальное поле "name" для экземпляра HTTP клиента!`);
|
|
@@ -107,6 +108,7 @@ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, header
|
|
|
107
108
|
const forceDisabledCircuitBreaker = envManager.get('HTTP_CLIENT_CIRCUIT_BREAKER_DISABLED');
|
|
108
109
|
const adapterOptions = tinkoffRequestHttpClientAdapter.mergeOptions({
|
|
109
110
|
logger,
|
|
111
|
+
agent,
|
|
110
112
|
method: 'GET',
|
|
111
113
|
createCache: createCache
|
|
112
114
|
? (cacheOptions) => createCache('memory', cacheOptions)
|
|
@@ -282,6 +284,10 @@ exports.HttpClientModule = tslib.__decorate([
|
|
|
282
284
|
token: tokensHttpClient.API_CLIENT_PASS_HEADERS,
|
|
283
285
|
optional: true,
|
|
284
286
|
},
|
|
287
|
+
agent: {
|
|
288
|
+
token: tokensHttpClient.HTTP_CLIENT_AGENT,
|
|
289
|
+
optional: true,
|
|
290
|
+
},
|
|
285
291
|
},
|
|
286
292
|
}),
|
|
287
293
|
core.provide({
|
|
@@ -353,3 +359,15 @@ exports.fillHeaderIp = fillHeaderIp;
|
|
|
353
359
|
exports.fillHeaders = fillHeaders;
|
|
354
360
|
exports.formatError = formatError;
|
|
355
361
|
exports.httpClientFactory = httpClientFactory;
|
|
362
|
+
Object.keys(tokensHttpClient).forEach(function (k) {
|
|
363
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
364
|
+
enumerable: true,
|
|
365
|
+
get: function () { return tokensHttpClient[k]; }
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
Object.keys(httpClient).forEach(function (k) {
|
|
369
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
370
|
+
enumerable: true,
|
|
371
|
+
get: function () { return httpClient[k]; }
|
|
372
|
+
});
|
|
373
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-http-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.46.5",
|
|
4
4
|
"initialVersion": "0.58.99",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@tramvai/http-client": "0.1.23",
|
|
28
|
-
"@tramvai/tinkoff-request-http-client-adapter": "0.8.
|
|
29
|
-
"@tramvai/tokens-http-client": "1.
|
|
30
|
-
"@tramvai/tokens-common": "1.
|
|
31
|
-
"@tramvai/tokens-server": "1.
|
|
28
|
+
"@tramvai/tinkoff-request-http-client-adapter": "0.8.205",
|
|
29
|
+
"@tramvai/tokens-http-client": "1.46.5",
|
|
30
|
+
"@tramvai/tokens-common": "1.46.5",
|
|
31
|
+
"@tramvai/tokens-server": "1.46.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@tinkoff/request-core": "^0.8.9"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@tinkoff/utils": "^2.1.2",
|
|
38
|
-
"@tramvai/core": "1.
|
|
39
|
-
"@tramvai/module-common": "1.
|
|
40
|
-
"@tramvai/papi": "1.
|
|
41
|
-
"@tramvai/test-helpers": "1.
|
|
42
|
-
"@tramvai/test-mocks": "1.
|
|
43
|
-
"@tinkoff/dippy": "0.7.
|
|
38
|
+
"@tramvai/core": "1.46.5",
|
|
39
|
+
"@tramvai/module-common": "1.46.5",
|
|
40
|
+
"@tramvai/papi": "1.46.5",
|
|
41
|
+
"@tramvai/test-helpers": "1.46.5",
|
|
42
|
+
"@tramvai/test-mocks": "1.46.5",
|
|
43
|
+
"@tinkoff/dippy": "0.7.36",
|
|
44
44
|
"node-fetch": "^2.6.1",
|
|
45
45
|
"tslib": "^2.0.3"
|
|
46
46
|
},
|