@tramvai/module-http-client 2.11.0 → 2.21.0

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.
@@ -1,10 +1,10 @@
1
1
  import type { MakeRequest } from '@tinkoff/request-core';
2
2
  import type { APP_INFO_TOKEN } from '@tramvai/core';
3
3
  import type { API_CLIENT_PASS_HEADERS, HttpClientFactoryOptions, HTTP_CLIENT_AGENT, HTTP_CLIENT_FACTORY, DISABLE_CIRCUIT_BREAKER } from '@tramvai/tokens-http-client';
4
- import type { LOGGER_TOKEN, CREATE_CACHE_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN } from '@tramvai/tokens-common';
4
+ import type { LOGGER_TOKEN, CREATE_CACHE_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN, COMMAND_LINE_EXECUTION_CONTEXT_TOKEN } from '@tramvai/tokens-common';
5
5
  import type { QuerySerializer } from '@tinkoff/request-plugin-protocol-http';
6
6
  import type { ExtractDependencyType, ExtractTokenType } from '@tinkoff/dippy';
7
- export declare const httpClientFactory: ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker, defaultOptions, }: {
7
+ export declare const httpClientFactory: ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker, defaultOptions, commandLineExecutionContext, }: {
8
8
  logger: ExtractDependencyType<typeof LOGGER_TOKEN>;
9
9
  envManager: ExtractDependencyType<typeof ENV_MANAGER_TOKEN>;
10
10
  appInfo: ExtractDependencyType<typeof APP_INFO_TOKEN>;
@@ -16,4 +16,5 @@ export declare const httpClientFactory: ({ logger, envManager, appInfo, requestM
16
16
  querySerializer?: QuerySerializer;
17
17
  disableCircuitBreaker: ExtractDependencyType<typeof DISABLE_CIRCUIT_BREAKER>;
18
18
  defaultOptions?: Partial<HttpClientFactoryOptions>;
19
+ commandLineExecutionContext?: ExtractDependencyType<typeof COMMAND_LINE_EXECUTION_CONTEXT_TOKEN>;
19
20
  }) => ExtractTokenType<typeof HTTP_CLIENT_FACTORY>;
@@ -2,7 +2,7 @@ import { createToken } from '@tinkoff/dippy';
2
2
  import { Module, provide, Scope, APP_INFO_TOKEN } from '@tramvai/core';
3
3
  import { PAPI_SERVICE, HTTP_CLIENT_FACTORY, API_CLIENT_PASS_HEADERS, HTTP_CLIENT_AGENT, DISABLE_CIRCUIT_BREAKER, DEFAULT_HTTP_CLIENT_FACTORY_OPTIONS, HTTP_CLIENT } from '@tramvai/tokens-http-client';
4
4
  export * from '@tramvai/tokens-http-client';
5
- import { LOGGER_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN, ENV_USED_TOKEN, CREATE_CACHE_TOKEN } from '@tramvai/tokens-common';
5
+ import { LOGGER_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN, COMMAND_LINE_EXECUTION_CONTEXT_TOKEN, ENV_USED_TOKEN, CREATE_CACHE_TOKEN } from '@tramvai/tokens-common';
6
6
  import isNil from '@tinkoff/utils/is/nil';
7
7
  import compose from '@tinkoff/utils/function/compose';
8
8
  import { mergeOptions, createTinkoffRequest, HttpClientAdapter } from '@tramvai/tinkoff-request-http-client-adapter';
@@ -38,8 +38,9 @@ const environmentDependentOptions = typeof window === 'undefined'
38
38
  : {
39
39
  defaultTimeout: 30000,
40
40
  };
41
- const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker = false, defaultOptions, }) => {
41
+ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker = false, defaultOptions, commandLineExecutionContext, }) => {
42
42
  return (options) => {
43
+ var _a;
43
44
  if (!options.name) {
44
45
  throw Error(`You need to pass a unique field "name" for the HTTP client instance`);
45
46
  }
@@ -58,6 +59,7 @@ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, header
58
59
  failureThreshold: 75,
59
60
  minimumFailureCount: 10,
60
61
  },
62
+ signal: (_a = commandLineExecutionContext === null || commandLineExecutionContext === void 0 ? void 0 : commandLineExecutionContext()) === null || _a === void 0 ? void 0 : _a.abortSignal,
61
63
  ...environmentDependentOptions,
62
64
  }, defaultOptions !== null && defaultOptions !== void 0 ? defaultOptions : {}), options);
63
65
  // по умолчанию, на сервере, библиотека https://github.com/node-fetch/node-fetch
@@ -163,6 +165,10 @@ const HttpClientModule = /* @__PURE__ */ Module({
163
165
  token: DEFAULT_HTTP_CLIENT_FACTORY_OPTIONS,
164
166
  optional: true,
165
167
  },
168
+ commandLineExecutionContext: {
169
+ token: COMMAND_LINE_EXECUTION_CONTEXT_TOKEN,
170
+ optional: true,
171
+ },
166
172
  },
167
173
  }),
168
174
  provide({
package/lib/index.es.js CHANGED
@@ -2,7 +2,7 @@ import { createChildContainer, createToken } from '@tinkoff/dippy';
2
2
  import { Module, provide, Scope, DI_TOKEN, APP_INFO_TOKEN } from '@tramvai/core';
3
3
  import { PAPI_SERVICE, HTTP_CLIENT_FACTORY, API_CLIENT_PASS_HEADERS, HTTP_CLIENT_AGENT, DISABLE_CIRCUIT_BREAKER, DEFAULT_HTTP_CLIENT_FACTORY_OPTIONS, HTTP_CLIENT } from '@tramvai/tokens-http-client';
4
4
  export * from '@tramvai/tokens-http-client';
5
- import { LOGGER_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN, ENV_USED_TOKEN, CREATE_CACHE_TOKEN } from '@tramvai/tokens-common';
5
+ import { LOGGER_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN, COMMAND_LINE_EXECUTION_CONTEXT_TOKEN, ENV_USED_TOKEN, CREATE_CACHE_TOKEN } from '@tramvai/tokens-common';
6
6
  import isNil from '@tinkoff/utils/is/nil';
7
7
  import compose from '@tinkoff/utils/function/compose';
8
8
  import { mergeOptions, createTinkoffRequest, HttpClientAdapter } from '@tramvai/tinkoff-request-http-client-adapter';
@@ -68,8 +68,9 @@ const environmentDependentOptions = typeof window === 'undefined'
68
68
  : {
69
69
  defaultTimeout: 30000,
70
70
  };
71
- const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker = false, defaultOptions, }) => {
71
+ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker = false, defaultOptions, commandLineExecutionContext, }) => {
72
72
  return (options) => {
73
+ var _a;
73
74
  if (!options.name) {
74
75
  throw Error(`You need to pass a unique field "name" for the HTTP client instance`);
75
76
  }
@@ -88,6 +89,7 @@ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, header
88
89
  failureThreshold: 75,
89
90
  minimumFailureCount: 10,
90
91
  },
92
+ signal: (_a = commandLineExecutionContext === null || commandLineExecutionContext === void 0 ? void 0 : commandLineExecutionContext()) === null || _a === void 0 ? void 0 : _a.abortSignal,
91
93
  ...environmentDependentOptions,
92
94
  }, defaultOptions !== null && defaultOptions !== void 0 ? defaultOptions : {}), options);
93
95
  // по умолчанию, на сервере, библиотека https://github.com/node-fetch/node-fetch
@@ -210,6 +212,10 @@ const HttpClientModule = /* @__PURE__ */ Module({
210
212
  token: DEFAULT_HTTP_CLIENT_FACTORY_OPTIONS,
211
213
  optional: true,
212
214
  },
215
+ commandLineExecutionContext: {
216
+ token: COMMAND_LINE_EXECUTION_CONTEXT_TOKEN,
217
+ optional: true,
218
+ },
213
219
  },
214
220
  }),
215
221
  provide({
package/lib/index.js CHANGED
@@ -79,8 +79,9 @@ const environmentDependentOptions = typeof window === 'undefined'
79
79
  : {
80
80
  defaultTimeout: 30000,
81
81
  };
82
- const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker = false, defaultOptions, }) => {
82
+ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker = false, defaultOptions, commandLineExecutionContext, }) => {
83
83
  return (options) => {
84
+ var _a;
84
85
  if (!options.name) {
85
86
  throw Error(`You need to pass a unique field "name" for the HTTP client instance`);
86
87
  }
@@ -99,6 +100,7 @@ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, header
99
100
  failureThreshold: 75,
100
101
  minimumFailureCount: 10,
101
102
  },
103
+ signal: (_a = commandLineExecutionContext === null || commandLineExecutionContext === void 0 ? void 0 : commandLineExecutionContext()) === null || _a === void 0 ? void 0 : _a.abortSignal,
102
104
  ...environmentDependentOptions,
103
105
  }, defaultOptions !== null && defaultOptions !== void 0 ? defaultOptions : {}), options);
104
106
  // по умолчанию, на сервере, библиотека https://github.com/node-fetch/node-fetch
@@ -221,6 +223,10 @@ const HttpClientModule = /* @__PURE__ */ core.Module({
221
223
  token: tokensHttpClient.DEFAULT_HTTP_CLIENT_FACTORY_OPTIONS,
222
224
  optional: true,
223
225
  },
226
+ commandLineExecutionContext: {
227
+ token: tokensCommon.COMMAND_LINE_EXECUTION_CONTEXT_TOKEN,
228
+ optional: true,
229
+ },
224
230
  },
225
231
  }),
226
232
  core.provide({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-http-client",
3
- "version": "2.11.0",
3
+ "version": "2.21.0",
4
4
  "initialVersion": "0.58.99",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
@@ -24,11 +24,11 @@
24
24
  "build-for-publish": "true"
25
25
  },
26
26
  "dependencies": {
27
- "@tramvai/http-client": "0.1.28",
28
- "@tramvai/tinkoff-request-http-client-adapter": "0.9.35",
29
- "@tramvai/tokens-http-client": "2.11.0",
30
- "@tramvai/tokens-common": "2.11.0",
31
- "@tramvai/tokens-server": "2.11.0"
27
+ "@tramvai/http-client": "0.2.2",
28
+ "@tramvai/tinkoff-request-http-client-adapter": "0.9.53",
29
+ "@tramvai/tokens-http-client": "2.21.0",
30
+ "@tramvai/tokens-common": "2.21.0",
31
+ "@tramvai/tokens-server": "2.21.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@tinkoff/request-core": "^0.9.2",
@@ -36,12 +36,12 @@
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@tinkoff/utils": "^2.1.2",
39
- "@tramvai/core": "2.11.0",
40
- "@tramvai/module-common": "2.11.0",
41
- "@tramvai/papi": "2.11.0",
42
- "@tramvai/test-helpers": "2.11.0",
43
- "@tramvai/test-mocks": "2.11.0",
44
- "@tinkoff/dippy": "0.7.45",
39
+ "@tramvai/core": "2.21.0",
40
+ "@tramvai/module-common": "2.21.0",
41
+ "@tramvai/papi": "2.21.0",
42
+ "@tramvai/test-helpers": "2.21.0",
43
+ "@tramvai/test-mocks": "2.21.0",
44
+ "@tinkoff/dippy": "0.8.2",
45
45
  "node-fetch": "^2.6.1",
46
46
  "tslib": "^2.0.3"
47
47
  },