@gravity-ui/gateway 3.0.4-alpha.0 → 3.0.4

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.
@@ -96,8 +96,8 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
96
96
  ? endpointData.path
97
97
  : endpointData;
98
98
  const endpointAxiosConfig = (0, common_1.isExtendedRestActionEndpoint)(endpointData)
99
- ? endpointData.axiosConfig || {}
100
- : {};
99
+ ? endpointData.axiosConfig
100
+ : undefined;
101
101
  const pathArgs = config.validationSchema
102
102
  ? (0, validate_1.encodePathParams)(args)
103
103
  : (0, validate_1.getPathArgsProxy)(args, options.encodePathArgs);
@@ -196,7 +196,7 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
196
196
  }
197
197
  const startRequestTime = Date.now();
198
198
  let axiosClient = defaultAxiosClient;
199
- const customActionTimeout = (_e = (_d = (_c = actionConfig.timeout) !== null && _c !== void 0 ? _c : config.timeout) !== null && _d !== void 0 ? _d : endpointAxiosConfig.timeout) !== null && _e !== void 0 ? _e : timeout;
199
+ const customActionTimeout = (_e = (_d = (_c = actionConfig.timeout) !== null && _c !== void 0 ? _c : config.timeout) !== null && _d !== void 0 ? _d : endpointAxiosConfig === null || endpointAxiosConfig === void 0 ? void 0 : endpointAxiosConfig.timeout) !== null && _e !== void 0 ? _e : timeout;
200
200
  if (actionConfig.timeout || endpointAxiosConfig) {
201
201
  const customActionAxiosConfig = Object.assign(Object.assign({}, ((options === null || options === void 0 ? void 0 : options.axiosConfig) || {})), (endpointAxiosConfig || {}));
202
202
  axiosClient = (0, axios_1.getAxiosClient)(customActionTimeout, config === null || config === void 0 ? void 0 : config.retries, customActionAxiosConfig);
@@ -231,17 +231,6 @@ function createRestAction(endpoints, config, serviceKey, actionName, options, Er
231
231
  responseType: config.responseType,
232
232
  });
233
233
  }
234
- axiosClient.interceptors.request.use((requestConfig) => {
235
- var _a;
236
- requestConfig.headers.set('x-request-attempt',
237
- // according this issue https://github.com/softonic/axios-retry/issues/167
238
- // 'axios-retry' doesn`t define retryCount field in exported type
239
- // however in this issue https://github.com/softonic/axios-retry/issues/75#issuecomment-502151719
240
- // people use it
241
- // @ts-ignore
242
- ((_a = requestConfig[constants_1.AXIOS_RETRY_NAMESPACE]) === null || _a === void 0 ? void 0 : _a.retryCount) || 0);
243
- return requestConfig;
244
- });
245
234
  try {
246
235
  const response = await axiosClient.request(requestConfig);
247
236
  const responseHeaders = {};
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getAxiosClient = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const axios_retry_1 = __importDefault(require("axios-retry"));
9
+ const lodash_1 = __importDefault(require("lodash"));
9
10
  const constants_1 = require("../constants");
10
11
  function getAxiosClient(timeout = constants_1.DEFAULT_TIMEOUT, retries = 0, axiosConfig = constants_1.DEFAULT_AXIOS_OPTIONS) {
11
12
  const client = axios_1.default.create(Object.assign(Object.assign({}, axiosConfig), { timeout }));
@@ -18,6 +19,9 @@ function getAxiosClient(timeout = constants_1.DEFAULT_TIMEOUT, retries = 0, axio
18
19
  }
19
20
  return axios_retry_1.default.isNetworkError(error) || axios_retry_1.default.isRetryableError(error);
20
21
  },
22
+ onRetry: (retryCount, _error, requestConfig) => {
23
+ lodash_1.default.set(requestConfig, ['headers', 'x-request-attempt'], retryCount);
24
+ },
21
25
  });
22
26
  return client;
23
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/gateway",
3
- "version": "3.0.4-alpha.0",
3
+ "version": "3.0.4",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/index.js",