@vtex/api 6.45.13-beta.1 → 6.45.13-beta.6
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
|
@@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
|
+
|
|
9
10
|
## [6.45.12] - 2022-04-14
|
|
11
|
+
|
|
10
12
|
### Fixed
|
|
11
13
|
- Update sensitive fields list.
|
|
12
14
|
- Remove "error" field.
|
|
@@ -1732,8 +1734,3 @@ instead
|
|
|
1732
1734
|
### Changed
|
|
1733
1735
|
|
|
1734
1736
|
- `HttpClient` now adds `'Accept-Encoding': 'gzip'` header by default.
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
[Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.45.11-beta.0...HEAD
|
|
1738
|
-
[6.45.11-beta.0]: https://github.com/vtex/node-vtex-api/compare/v6.45.11-beta...v6.45.11-beta.0
|
|
1739
|
-
[6.45.11-beta]: https://github.com/vtex/node-vtex-api/compare/v6.45.10...v6.45.11-beta
|
|
@@ -6,6 +6,7 @@ import { InstanceOptions, IOResponse, RequestConfig } from './typings';
|
|
|
6
6
|
declare type ClientOptions = IOContext & Partial<InstanceOptions>;
|
|
7
7
|
export declare class HttpClient {
|
|
8
8
|
name: string;
|
|
9
|
+
private logger;
|
|
9
10
|
private runMiddlewares;
|
|
10
11
|
constructor(opts: ClientOptions);
|
|
11
12
|
get: <T = any>(url: string, config?: RequestConfig) => Promise<T>;
|
|
@@ -31,7 +31,19 @@ class HttpClient {
|
|
|
31
31
|
return this.request(cacheableConfig);
|
|
32
32
|
};
|
|
33
33
|
this.getWithBody = (url, data, config = {}) => {
|
|
34
|
-
const
|
|
34
|
+
const deterministicReplacer = (_, v) => {
|
|
35
|
+
try {
|
|
36
|
+
return typeof v !== 'object' || v === null || Array.isArray(v) ? v :
|
|
37
|
+
Object.fromEntries(Object.entries(v).sort(([ka], [kb]) => ka < kb ? -1 : ka > kb ? 1 : 0));
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
// I don't believe this will ever happen, but just in case
|
|
41
|
+
// Also, I didn't include error as I am unsure if it would have sensitive information
|
|
42
|
+
this.logger.warn({ message: 'Error while sorting object for cache key' });
|
|
43
|
+
return v;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const bodyHash = crypto_1.createHash('md5').update(JSON.stringify(data, deterministicReplacer)).digest('hex');
|
|
35
47
|
const cacheableConfig = this.getConfig(url, {
|
|
36
48
|
...config,
|
|
37
49
|
data,
|
|
@@ -91,6 +103,7 @@ class HttpClient {
|
|
|
91
103
|
});
|
|
92
104
|
const { baseURL, authToken, authType, memoryCache, diskCache, locale, name, metrics, product, serverTiming, recorder, userAgent, timeout = DEFAULT_TIMEOUT_MS, segmentToken, sessionToken, retries, concurrency, headers: defaultHeaders, host, params, operationId, tenant, binding, verbose, cancellation, exponentialTimeoutCoefficient, initialBackoffDelay, exponentialBackoffCoefficient, httpsAgent, tracer, logger, } = opts;
|
|
93
105
|
this.name = name || baseURL || 'unknown';
|
|
106
|
+
this.logger = logger;
|
|
94
107
|
const limit = concurrency && concurrency > 0 && p_limit_1.default(concurrency) || undefined;
|
|
95
108
|
const headers = {
|
|
96
109
|
...defaultHeaders,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IOContext, TracingContext } from '../typings';
|
|
2
|
-
export declare const prepareHandlerCtx: (header: any, tracingContext: TracingContext) => Pick<IOContext, "host" | "
|
|
2
|
+
export declare const prepareHandlerCtx: (header: any, tracingContext: TracingContext) => Pick<IOContext, "host" | "serverTiming" | "locale" | "account" | "workspace" | "region" | "logger" | "requestId" | "operationId" | "production" | "platform" | "authToken" | "adminUserAuthToken" | "storeUserAuthToken" | "product" | "recorder" | "userAgent" | "segmentToken" | "sessionToken" | "janusEnv" | "eventInfo" | "tenant" | "binding" | "cancellation" | "settings" | "tracer">;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtex/api",
|
|
3
|
-
"version": "6.45.13-beta.
|
|
3
|
+
"version": "6.45.13-beta.6",
|
|
4
4
|
"description": "VTEX I/O API client",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"fs-extra": "^7.0.0",
|
|
66
66
|
"graphql": "^14.5.8",
|
|
67
67
|
"graphql-tools": "^4.0.6",
|
|
68
|
-
"graphql-upload": "^
|
|
69
|
-
"jaeger-client": "^3.
|
|
68
|
+
"graphql-upload": "^8.1.0",
|
|
69
|
+
"jaeger-client": "^3.18.0",
|
|
70
70
|
"js-base64": "^2.5.1",
|
|
71
71
|
"koa": "^2.11.0",
|
|
72
72
|
"koa-compose": "^4.1.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"mime-types": "^2.1.12",
|
|
77
77
|
"opentracing": "^0.14.4",
|
|
78
78
|
"p-limit": "^2.2.0",
|
|
79
|
-
"prom-client": "^
|
|
79
|
+
"prom-client": "^12.0.0",
|
|
80
80
|
"qs": "^6.5.1",
|
|
81
81
|
"querystring": "^0.2.0",
|
|
82
82
|
"ramda": "^0.26.0",
|
|
@@ -97,7 +97,8 @@
|
|
|
97
97
|
"@types/fast-json-stable-stringify": "^2.0.0",
|
|
98
98
|
"@types/fs-extra": "^5.0.0",
|
|
99
99
|
"@types/graphql": "^14.5.0",
|
|
100
|
-
"@types/
|
|
100
|
+
"@types/graphql-upload": "^8.0.3",
|
|
101
|
+
"@types/jaeger-client": "^3.15.3",
|
|
101
102
|
"@types/jest": "^25.1.4",
|
|
102
103
|
"@types/js-base64": "^2.3.1",
|
|
103
104
|
"@types/koa-compress": "^2.0.9",
|