@tramvai/module-http-client 2.6.2 → 2.10.2

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/README.md CHANGED
@@ -101,13 +101,13 @@ The `HTTP_CLIENT` token provides a basic client for sending requests to any URLs
101
101
  **Token use:**
102
102
 
103
103
  ```tsx
104
- import { createAction } from '@tramvai/core';
104
+ import { declareAction } from '@tramvai/core';
105
105
  import { HTTP_CLIENT } from '@tramvai/tokens-http-client';
106
106
 
107
- export const fetchAction = createAction({
107
+ export const fetchAction = declareAction({
108
108
  name: 'fetch',
109
- fn: async (_, __, { httpClient }) => {
110
- const { payload, headers, status } = await httpClient.get(
109
+ async fn() {
110
+ const { payload, headers, status } = await this.deps.httpClient.get(
111
111
  'https://www.domain.com/api/endpoint'
112
112
  );
113
113
  return payload;
@@ -2,8 +2,9 @@ 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
4
  import type { LOGGER_TOKEN, CREATE_CACHE_TOKEN, ENV_MANAGER_TOKEN, REQUEST_MANAGER_TOKEN } from '@tramvai/tokens-common';
5
+ import type { QuerySerializer } from '@tinkoff/request-plugin-protocol-http';
5
6
  import type { ExtractDependencyType, ExtractTokenType } from '@tinkoff/dippy';
6
- export declare const httpClientFactory: ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, disableCircuitBreaker, defaultOptions, }: {
7
+ export declare const httpClientFactory: ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker, defaultOptions, }: {
7
8
  logger: ExtractDependencyType<typeof LOGGER_TOKEN>;
8
9
  envManager: ExtractDependencyType<typeof ENV_MANAGER_TOKEN>;
9
10
  appInfo: ExtractDependencyType<typeof APP_INFO_TOKEN>;
@@ -12,6 +13,7 @@ export declare const httpClientFactory: ({ logger, envManager, appInfo, requestM
12
13
  createCache?: ExtractDependencyType<typeof CREATE_CACHE_TOKEN>;
13
14
  makeRequestRegistry: Map<string, MakeRequest>;
14
15
  agent?: ExtractDependencyType<typeof HTTP_CLIENT_AGENT>;
16
+ querySerializer?: QuerySerializer;
15
17
  disableCircuitBreaker: ExtractDependencyType<typeof DISABLE_CIRCUIT_BREAKER>;
16
18
  defaultOptions?: Partial<HttpClientFactoryOptions>;
17
19
  }) => ExtractTokenType<typeof HTTP_CLIENT_FACTORY>;
@@ -38,7 +38,7 @@ const environmentDependentOptions = typeof window === 'undefined'
38
38
  : {
39
39
  defaultTimeout: 30000,
40
40
  };
41
- const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, disableCircuitBreaker = false, defaultOptions, }) => {
41
+ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker = false, defaultOptions, }) => {
42
42
  return (options) => {
43
43
  if (!options.name) {
44
44
  throw Error(`You need to pass a unique field "name" for the HTTP client instance`);
@@ -48,6 +48,7 @@ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, header
48
48
  const adapterOptions = mergeOptions(mergeOptions({
49
49
  logger,
50
50
  agent,
51
+ querySerializer,
51
52
  method: 'GET',
52
53
  createCache: createCache
53
54
  ? (cacheOptions) => createCache('memory', cacheOptions)
package/lib/index.es.js CHANGED
@@ -68,7 +68,7 @@ const environmentDependentOptions = typeof window === 'undefined'
68
68
  : {
69
69
  defaultTimeout: 30000,
70
70
  };
71
- const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, disableCircuitBreaker = false, defaultOptions, }) => {
71
+ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker = false, defaultOptions, }) => {
72
72
  return (options) => {
73
73
  if (!options.name) {
74
74
  throw Error(`You need to pass a unique field "name" for the HTTP client instance`);
@@ -78,6 +78,7 @@ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, header
78
78
  const adapterOptions = mergeOptions(mergeOptions({
79
79
  logger,
80
80
  agent,
81
+ querySerializer,
81
82
  method: 'GET',
82
83
  createCache: createCache
83
84
  ? (cacheOptions) => createCache('memory', cacheOptions)
package/lib/index.js CHANGED
@@ -79,7 +79,7 @@ const environmentDependentOptions = typeof window === 'undefined'
79
79
  : {
80
80
  defaultTimeout: 30000,
81
81
  };
82
- const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, disableCircuitBreaker = false, defaultOptions, }) => {
82
+ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, headersList, createCache, makeRequestRegistry, agent, querySerializer, disableCircuitBreaker = false, defaultOptions, }) => {
83
83
  return (options) => {
84
84
  if (!options.name) {
85
85
  throw Error(`You need to pass a unique field "name" for the HTTP client instance`);
@@ -89,6 +89,7 @@ const httpClientFactory = ({ logger, envManager, appInfo, requestManager, header
89
89
  const adapterOptions = tinkoffRequestHttpClientAdapter.mergeOptions(tinkoffRequestHttpClientAdapter.mergeOptions({
90
90
  logger,
91
91
  agent,
92
+ querySerializer,
92
93
  method: 'GET',
93
94
  createCache: createCache
94
95
  ? (cacheOptions) => createCache('memory', cacheOptions)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-http-client",
3
- "version": "2.6.2",
3
+ "version": "2.10.2",
4
4
  "initialVersion": "0.58.99",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
@@ -25,22 +25,23 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@tramvai/http-client": "0.1.28",
28
- "@tramvai/tinkoff-request-http-client-adapter": "0.9.22",
29
- "@tramvai/tokens-http-client": "2.6.2",
30
- "@tramvai/tokens-common": "2.6.2",
31
- "@tramvai/tokens-server": "2.6.2"
28
+ "@tramvai/tinkoff-request-http-client-adapter": "0.9.33",
29
+ "@tramvai/tokens-http-client": "2.10.2",
30
+ "@tramvai/tokens-common": "2.10.2",
31
+ "@tramvai/tokens-server": "2.10.2"
32
32
  },
33
33
  "devDependencies": {
34
- "@tinkoff/request-core": "^0.9.2"
34
+ "@tinkoff/request-core": "^0.9.2",
35
+ "@tinkoff/request-plugin-protocol-http": "^0.11.6"
35
36
  },
36
37
  "peerDependencies": {
37
38
  "@tinkoff/utils": "^2.1.2",
38
- "@tramvai/core": "2.6.2",
39
- "@tramvai/module-common": "2.6.2",
40
- "@tramvai/papi": "2.6.2",
41
- "@tramvai/test-helpers": "2.6.2",
42
- "@tramvai/test-mocks": "2.6.2",
43
- "@tinkoff/dippy": "0.7.44",
39
+ "@tramvai/core": "2.10.2",
40
+ "@tramvai/module-common": "2.10.2",
41
+ "@tramvai/papi": "2.10.2",
42
+ "@tramvai/test-helpers": "2.10.2",
43
+ "@tramvai/test-mocks": "2.10.2",
44
+ "@tinkoff/dippy": "0.7.45",
44
45
  "node-fetch": "^2.6.1",
45
46
  "tslib": "^2.0.3"
46
47
  },