@vtex/api 6.45.15 → 6.46.0-beta.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [6.46.0-beta.0] - 2023-03-07
11
+
12
+ ## [6.46.0-beta] - 2023-03-07
13
+
10
14
  ## [6.45.15] - 2023-02-01
11
15
  ### Changed
12
16
  - Removed unnecessary worker signal logs
@@ -1757,7 +1761,9 @@ instead
1757
1761
  - `HttpClient` now adds `'Accept-Encoding': 'gzip'` header by default.
1758
1762
 
1759
1763
 
1760
- [Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.45.15...HEAD
1764
+ [Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.46.0-beta.0...HEAD
1765
+ [6.46.0-beta.0]: https://github.com/vtex/node-vtex-api/compare/v6.46.0-beta...v6.46.0-beta.0
1766
+ [6.46.0-beta]: https://github.com/vtex/node-vtex-api/compare/v6.45.15...v6.46.0-beta
1761
1767
  [6.45.15]: https://github.com/vtex/node-vtex-api/compare/v6.45.14...v6.45.15
1762
1768
  [6.45.14]: https://github.com/vtex/node-vtex-api/compare/v6.45.13...v6.45.14
1763
1769
  [6.45.13]: https://github.com/vtex/node-vtex-api/compare/v6.45.12...v6.45.13
@@ -24,7 +24,7 @@ export declare class HttpClient {
24
24
  patch: <T = void>(url: string, data?: any, config?: RequestConfig) => Promise<T>;
25
25
  head: (url: string, config?: RequestConfig) => Promise<IOResponse<void>>;
26
26
  delete: <T = void>(url: string, config?: RequestConfig | undefined) => Promise<IOResponse<T>>;
27
- protected request: (config: RequestConfig) => Promise<AxiosResponse<any>>;
27
+ protected request: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
28
28
  private getConfig;
29
29
  }
30
30
  export {};
@@ -2,7 +2,7 @@
2
2
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
3
3
  import { CacheLayer } from '../../caches/CacheLayer';
4
4
  import { MiddlewareContext, RequestConfig } from '../typings';
5
- export declare const cacheKey: (config: AxiosRequestConfig) => string;
5
+ export declare const cacheKey: (config: AxiosRequestConfig<any>) => string;
6
6
  export declare function isLocallyCacheable(arg: RequestConfig, type: CacheType): arg is CacheableRequestConfig;
7
7
  export declare enum CacheType {
8
8
  None = 0,
@@ -5,7 +5,7 @@ const RANGE_HEADER_QS_KEY = '__range_header';
5
5
  const cacheableStatusCodes = [200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501]; // https://tools.ietf.org/html/rfc7231#section-6.1
6
6
  exports.cacheKey = (config) => {
7
7
  const { baseURL = '', url = '', params, headers } = config;
8
- const locale = headers[constants_1.LOCALE_HEADER];
8
+ const locale = headers === null || headers === void 0 ? void 0 : headers[constants_1.LOCALE_HEADER];
9
9
  const encodedBaseURL = baseURL.replace(/\//g, '\\');
10
10
  const encodedURL = url.replace(/\//g, '\\');
11
11
  let key = `${locale}--${encodedBaseURL}--${encodedURL}?`;
@@ -55,12 +55,13 @@ exports.cacheMiddleware = ({ type, storage }) => {
55
55
  const CACHE_RESULT_TAG = type === CacheType.Disk ? "http.cache.disk" /* HTTP_DISK_CACHE_RESULT */ : "http.cache.memory" /* HTTP_MEMORY_CACHE_RESULT */;
56
56
  const cacheType = CacheTypeNames[type];
57
57
  return async (ctx, next) => {
58
+ var _a;
58
59
  if (!isLocallyCacheable(ctx.config, type)) {
59
60
  return await next();
60
61
  }
61
62
  const span = ctx.tracing.rootSpan;
62
63
  const key = exports.cacheKey(ctx.config);
63
- const segmentToken = ctx.config.headers[constants_1.SEGMENT_HEADER];
64
+ const segmentToken = (_a = ctx.config.headers) === null || _a === void 0 ? void 0 : _a[constants_1.SEGMENT_HEADER];
64
65
  const keyWithSegment = key + segmentToken;
65
66
  span.log({
66
67
  event: "cache-key-created" /* CACHE_KEY_CREATE */,
@@ -97,6 +98,9 @@ exports.cacheMiddleware = ({ type, storage }) => {
97
98
  span.setTag(CACHE_RESULT_TAG, "STALE" /* STALE */);
98
99
  const validateStatus = addNotModified(ctx.config.validateStatus);
99
100
  if (cachedEtag && validateStatus(response.status)) {
101
+ if (!ctx.config.headers) {
102
+ ctx.config.headers = {};
103
+ }
100
104
  ctx.config.headers['if-none-match'] = cachedEtag;
101
105
  ctx.config.validateStatus = validateStatus;
102
106
  }
@@ -144,7 +148,7 @@ exports.cacheMiddleware = ({ type, storage }) => {
144
148
  const currentAge = revalidated ? 0 : age;
145
149
  const varySegment = ctx.response.headers.vary && ctx.response.headers.vary.includes(constants_1.SEGMENT_HEADER);
146
150
  const setKey = varySegment ? keyWithSegment : key;
147
- const responseEncoding = configResponseEncoding || (responseType === 'arraybuffer' ? 'base64' : undefined);
151
+ const responseEncoding = (configResponseEncoding || (responseType === 'arraybuffer' ? 'base64' : undefined));
148
152
  const cacheableData = type === CacheType.Disk && responseType === 'arraybuffer'
149
153
  ? data.toString(responseEncoding)
150
154
  : data;
@@ -1,4 +1,4 @@
1
1
  import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
2
2
  import { Span } from 'opentracing';
3
- export declare const injectRequestInfoOnSpan: (span: Span, http: AxiosInstance, config: AxiosRequestConfig) => void;
4
- export declare const injectResponseInfoOnSpan: (span: Span, response: AxiosResponse<any> | undefined) => void;
3
+ export declare const injectRequestInfoOnSpan: (span: Span, http: AxiosInstance, config: AxiosRequestConfig<any>) => void;
4
+ export declare const injectResponseInfoOnSpan: (span: Span, response: AxiosResponse<any, any> | undefined) => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
3
2
  import { Middleware } from 'koa-compose';
4
3
  import { Span } from 'opentracing';
@@ -44,7 +43,6 @@ export interface RequestConfig extends AxiosRequestConfig, RequestTracingConfig
44
43
  memoizeable?: boolean;
45
44
  inflightKey?: InflightKeyGenerator;
46
45
  forceMaxAge?: number;
47
- responseEncoding?: BufferEncoding;
48
46
  nullIfNotFound?: boolean;
49
47
  ignoreRecorder?: boolean;
50
48
  }
@@ -138,7 +138,7 @@ class VBase extends InfraClient_1.InfraClient {
138
138
  return this.saveContent(bucket, path, stream, { unzip: true }, tracingConfig, ifMatch);
139
139
  };
140
140
  this.deleteFile = (bucket, path, tracingConfig, ifMatch) => {
141
- const headers = ifMatch ? { 'If-Match': ifMatch } : null;
141
+ const headers = ifMatch ? { 'If-Match': ifMatch } : {};
142
142
  const metric = 'vbase-delete-file';
143
143
  return this.http.delete(routes.File(bucket, path), { headers, metric, tracing: {
144
144
  requestSpanNameSuffix: metric,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "6.45.15",
3
+ "version": "6.46.0-beta.0",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -54,7 +54,7 @@
54
54
  "agentkeepalive": "^4.0.2",
55
55
  "apollo-server-errors": "^2.2.1",
56
56
  "archiver": "^3.0.0",
57
- "axios": "^0.21.1",
57
+ "axios": "0.27.2",
58
58
  "axios-retry": "^3.1.2",
59
59
  "bluebird": "^3.5.4",
60
60
  "chalk": "^2.4.2",