Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update axios version #524

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [6.46.0-beta.0] - 2023-03-07

## [6.46.0-beta] - 2023-03-07

## [6.45.15] - 2023-02-01
### Changed
- Removed unnecessary worker signal logs
Expand Down Expand Up @@ -1757,7 +1761,9 @@ instead
- `HttpClient` now adds `'Accept-Encoding': 'gzip'` header by default.


[Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.45.15...HEAD
[Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.46.0-beta.0...HEAD
[6.46.0-beta.0]: https://github.com/vtex/node-vtex-api/compare/v6.46.0-beta...v6.46.0-beta.0
[6.46.0-beta]: https://github.com/vtex/node-vtex-api/compare/v6.45.15...v6.46.0-beta
[6.45.15]: https://github.com/vtex/node-vtex-api/compare/v6.45.14...v6.45.15
[6.45.14]: https://github.com/vtex/node-vtex-api/compare/v6.45.13...v6.45.14
[6.45.13]: https://github.com/vtex/node-vtex-api/compare/v6.45.12...v6.45.13
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vtex/api",
"version": "6.45.15",
"version": "6.46.0-beta.0",
"description": "VTEX I/O API client",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -54,7 +54,7 @@
"agentkeepalive": "^4.0.2",
"apollo-server-errors": "^2.2.1",
"archiver": "^3.0.0",
"axios": "^0.21.1",
"axios": "0.27.2",
"axios-retry": "^3.1.2",
"bluebird": "^3.5.4",
"chalk": "^2.4.2",
Expand Down
9 changes: 6 additions & 3 deletions src/HttpClient/middlewares/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const cacheableStatusCodes = [200, 203, 204, 206, 300, 301, 404, 405, 410, 414,

export const cacheKey = (config: AxiosRequestConfig) => {
const {baseURL = '', url = '', params, headers} = config
const locale = headers[LOCALE_HEADER]
const locale = headers?.[LOCALE_HEADER]

const encodedBaseURL = baseURL.replace(/\//g, '\\')
const encodedURL = url.replace(/\//g, '\\')
Expand Down Expand Up @@ -93,7 +93,7 @@ export const cacheMiddleware = ({ type, storage }: CacheOptions) => {
const span = ctx.tracing!.rootSpan

const key = cacheKey(ctx.config)
const segmentToken = ctx.config.headers[SEGMENT_HEADER]
const segmentToken = ctx.config.headers?.[SEGMENT_HEADER]
const keyWithSegment = key + segmentToken

span.log({
Expand Down Expand Up @@ -139,6 +139,9 @@ export const cacheMiddleware = ({ type, storage }: CacheOptions) => {
span.setTag(CACHE_RESULT_TAG, CacheResult.STALE)
const validateStatus = addNotModified(ctx.config.validateStatus!)
if (cachedEtag && validateStatus(response.status as number)) {
if (!ctx.config.headers) {
ctx.config.headers = {}
}
ctx.config.headers['if-none-match'] = cachedEtag
ctx.config.validateStatus = validateStatus
}
Expand Down Expand Up @@ -193,7 +196,7 @@ export const cacheMiddleware = ({ type, storage }: CacheOptions) => {
const currentAge = revalidated ? 0 : age
const varySegment = ctx.response.headers.vary && ctx.response.headers.vary.includes(SEGMENT_HEADER)
const setKey = varySegment ? keyWithSegment : key
const responseEncoding = configResponseEncoding || (responseType === 'arraybuffer' ? 'base64' : undefined)
const responseEncoding = (configResponseEncoding || (responseType === 'arraybuffer' ? 'base64' : undefined)) as BufferEncoding
const cacheableData = type === CacheType.Disk && responseType === 'arraybuffer'
? (data as Buffer).toString(responseEncoding)
: data
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient/middlewares/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const defaultsMiddleware = ({ baseURL, rawHeaders, params, timeout, retri
...ctx.config,
headers: {
...headers,
...renameBy(toLower, ctx.config.headers),
...renameBy(toLower, ctx.config.headers!),
},
params: {
...params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const injectRequestInfoOnSpan = (span: Span, http: AxiosInstance, config:
[OpentracingTags.HTTP_URL]: buildFullPath(config.baseURL, http.getUri(config)),
})

span.log({ 'request-headers': cloneAndSanitizeHeaders(config.headers) })
span.log({ 'request-headers': cloneAndSanitizeHeaders(config.headers!) })
}

// Response may be undefined in case of client timeout, invalid URL, ...
Expand Down
1 change: 0 additions & 1 deletion src/HttpClient/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export interface RequestConfig extends AxiosRequestConfig, RequestTracingConfig
memoizeable?: boolean
inflightKey?: InflightKeyGenerator
forceMaxAge?: number
responseEncoding?: BufferEncoding
nullIfNotFound?: boolean
ignoreRecorder?: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion src/clients/infra/VBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class VBase extends InfraClient {
}

public deleteFile = (bucket: string, path: string, tracingConfig?: RequestTracingConfig, ifMatch?: string) => {
const headers = ifMatch ? { 'If-Match': ifMatch } : null
const headers = ifMatch ? { 'If-Match': ifMatch } : {} as Record<string, string>
const metric = 'vbase-delete-file'
return this.http.delete(routes.File(bucket, path), {headers, metric, tracing: {
requestSpanNameSuffix: metric,
Expand Down
32 changes: 21 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1025,12 +1025,13 @@ axios-retry@^3.1.2:
dependencies:
is-retry-allowed "^1.1.0"

axios@^0.21.1:
version "0.21.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==
axios@0.27.2:
version "0.27.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
dependencies:
follow-redirects "^1.10.0"
follow-redirects "^1.14.9"
form-data "^4.0.0"

babel-jest@^25.1.0:
version "25.1.0"
Expand Down Expand Up @@ -1383,7 +1384,7 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

combined-stream@^1.0.6, combined-stream@~1.0.6:
combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
Expand Down Expand Up @@ -1978,10 +1979,10 @@ find-up@^4.0.0, find-up@^4.1.0:
locate-path "^5.0.0"
path-exists "^4.0.0"

follow-redirects@^1.10.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43"
integrity sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==
follow-redirects@^1.14.9:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==

for-in@^1.0.2:
version "1.0.2"
Expand All @@ -1993,6 +1994,15 @@ forever-agent@~0.6.1:
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=

form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"

form-data@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6"
Expand Down Expand Up @@ -5117,4 +5127,4 @@ zip-stream@^2.1.2:
dependencies:
archiver-utils "^2.1.0"
compress-commons "^2.1.1"
readable-stream "^3.4.0"
readable-stream "^3.4.0"