@vtex/api 6.48.1-beta.3 → 6.49.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/gen/manifest.schema +1 -1
- package/lib/HttpClient/GraphQLClient.d.ts +1 -1
- package/lib/HttpClient/HttpClient.d.ts +3 -2
- package/lib/HttpClient/HttpClient.js +14 -14
- package/lib/HttpClient/agents.d.ts +5 -2
- package/lib/HttpClient/agents.js +10 -4
- package/lib/HttpClient/index.js +7 -2
- package/lib/HttpClient/middlewares/cache.d.ts +1 -1
- package/lib/HttpClient/middlewares/cache.js +43 -44
- package/lib/HttpClient/middlewares/cancellationToken.d.ts +1 -1
- package/lib/HttpClient/middlewares/cancellationToken.js +2 -1
- package/lib/HttpClient/middlewares/inflight.d.ts +1 -1
- package/lib/HttpClient/middlewares/inflight.js +6 -3
- package/lib/HttpClient/middlewares/memoization.d.ts +1 -1
- package/lib/HttpClient/middlewares/memoization.js +9 -8
- package/lib/HttpClient/middlewares/metrics.js +8 -11
- package/lib/HttpClient/middlewares/notFound.d.ts +1 -1
- package/lib/HttpClient/middlewares/notFound.js +4 -2
- package/lib/HttpClient/middlewares/recorder.js +2 -5
- package/lib/HttpClient/middlewares/request/HttpAgentSingleton.js +1 -1
- package/lib/HttpClient/middlewares/request/index.d.ts +1 -1
- package/lib/HttpClient/middlewares/request/index.js +13 -10
- package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +0 -1
- package/lib/HttpClient/middlewares/request/setupAxios/index.js +5 -4
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +6 -5
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +1 -0
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +8 -8
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +10 -8
- package/lib/HttpClient/middlewares/tracing.js +11 -14
- package/lib/HttpClient/typings.d.ts +3 -3
- package/lib/caches/DiskCache.js +3 -3
- package/lib/caches/LRUCache.d.ts +2 -2
- package/lib/caches/LRUDiskCache.d.ts +1 -1
- package/lib/caches/LRUDiskCache.js +3 -3
- package/lib/caches/MultilayeredCache.d.ts +2 -2
- package/lib/caches/MultilayeredCache.js +7 -7
- package/lib/caches/index.js +6 -2
- package/lib/caches/typings.d.ts +5 -5
- package/lib/clients/IOClient.d.ts +1 -1
- package/lib/clients/IOClients.d.ts +1 -1
- package/lib/clients/apps/AppClient.js +1 -1
- package/lib/clients/apps/AppGraphQLClient.js +1 -1
- package/lib/clients/apps/Billing.d.ts +1 -1
- package/lib/clients/apps/Builder.d.ts +7 -7
- package/lib/clients/apps/Builder.js +1 -1
- package/lib/clients/apps/MessagesGraphQL.d.ts +1 -1
- package/lib/clients/apps/MessagesGraphQL.js +3 -3
- package/lib/clients/apps/Settings.js +3 -3
- package/lib/clients/apps/catalogGraphQL/index.d.ts +4 -4
- package/lib/clients/apps/catalogGraphQL/index.js +4 -4
- package/lib/clients/apps/index.js +6 -2
- package/lib/clients/external/ID.d.ts +4 -4
- package/lib/clients/external/PaymentProvider.d.ts +2 -2
- package/lib/clients/external/index.js +6 -2
- package/lib/clients/index.js +6 -2
- package/lib/clients/infra/Apps.d.ts +32 -27
- package/lib/clients/infra/Apps.js +16 -18
- package/lib/clients/infra/Assets.d.ts +6 -5
- package/lib/clients/infra/Assets.js +11 -11
- package/lib/clients/infra/BillingMetrics.d.ts +1 -1
- package/lib/clients/infra/Events.d.ts +1 -1
- package/lib/clients/infra/Events.js +1 -1
- package/lib/clients/infra/Housekeeper.d.ts +3 -3
- package/lib/clients/infra/Registry.d.ts +23 -17
- package/lib/clients/infra/Registry.js +3 -4
- package/lib/clients/infra/Router.d.ts +8 -8
- package/lib/clients/infra/Sphinx.d.ts +2 -2
- package/lib/clients/infra/VBase.d.ts +15 -14
- package/lib/clients/infra/VBase.js +3 -3
- package/lib/clients/infra/Workspaces.d.ts +7 -7
- package/lib/clients/infra/index.js +6 -2
- package/lib/clients/janus/JanusClient.d.ts +1 -1
- package/lib/clients/janus/LicenseManager.js +1 -1
- package/lib/clients/janus/Segment.d.ts +3 -3
- package/lib/clients/janus/Segment.js +2 -2
- package/lib/clients/janus/Session.d.ts +2 -2
- package/lib/clients/janus/Tenant.d.ts +1 -1
- package/lib/clients/janus/index.js +6 -2
- package/lib/constants.d.ts +2 -1
- package/lib/constants.js +3 -2
- package/lib/errors/ResolverError.js +1 -1
- package/lib/errors/index.js +6 -2
- package/lib/index.js +6 -2
- package/lib/metrics/MetricsAccumulator.d.ts +2 -2
- package/lib/metrics/MetricsAccumulator.js +9 -9
- package/lib/responses.d.ts +4 -4
- package/lib/service/index.js +7 -9
- package/lib/service/loaders.js +8 -6
- package/lib/service/logger/client.d.ts +2 -0
- package/lib/service/logger/client.js +48 -0
- package/lib/service/logger/console.d.ts +1 -1
- package/lib/service/logger/console.js +7 -4
- package/lib/service/logger/index.d.ts +2 -0
- package/lib/service/logger/index.js +8 -2
- package/lib/service/logger/logger.d.ts +4 -15
- package/lib/service/logger/logger.js +61 -18
- package/lib/service/logger/loggerTypes.d.ts +14 -0
- package/lib/service/logger/loggerTypes.js +10 -0
- package/lib/service/logger/metricsLogger.js +10 -10
- package/lib/service/master.js +7 -6
- package/lib/service/metrics/requestMetricsMiddleware.js +14 -13
- package/lib/service/telemetry/client.d.ts +3 -0
- package/lib/service/telemetry/client.js +57 -0
- package/lib/service/telemetry/index.d.ts +1 -0
- package/lib/service/telemetry/index.js +17 -0
- package/lib/service/tracing/TracerSingleton.js +9 -9
- package/lib/service/tracing/metrics/MetricNames.js +12 -12
- package/lib/service/tracing/metrics/instruments.js +14 -7
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +5 -5
- package/lib/service/tracing/tracingMiddlewares.js +18 -21
- package/lib/service/worker/index.js +25 -24
- package/lib/service/worker/listeners.js +2 -1
- package/lib/service/worker/runtime/Service.js +1 -1
- package/lib/service/worker/runtime/builtIn/handlers.js +6 -3
- package/lib/service/worker/runtime/builtIn/middlewares.js +5 -3
- package/lib/service/worker/runtime/events/index.d.ts +1 -1
- package/lib/service/worker/runtime/events/index.js +11 -10
- package/lib/service/worker/runtime/events/middlewares/body.js +3 -6
- package/lib/service/worker/runtime/events/middlewares/context.js +1 -1
- package/lib/service/worker/runtime/events/router.js +3 -2
- package/lib/service/worker/runtime/graphql/index.js +8 -7
- package/lib/service/worker/runtime/graphql/middlewares/error.js +5 -8
- package/lib/service/worker/runtime/graphql/middlewares/query.js +7 -6
- package/lib/service/worker/runtime/graphql/middlewares/response.js +1 -1
- package/lib/service/worker/runtime/graphql/middlewares/run.js +3 -2
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +4 -3
- package/lib/service/worker/runtime/graphql/middlewares/upload.js +1 -1
- package/lib/service/worker/runtime/graphql/schema/index.d.ts +1 -1
- package/lib/service/worker/runtime/graphql/schema/index.js +8 -7
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +2 -2
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +4 -3
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.js +1 -1
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Deprecated.js +1 -1
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Settings.js +1 -1
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslatableV2.js +2 -2
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/TranslateTo.js +2 -2
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +1 -1
- package/lib/service/worker/runtime/graphql/schema/typeDefs/index.js +2 -1
- package/lib/service/worker/runtime/graphql/schema/typeDefs/sanitizedString.js +2 -2
- package/lib/service/worker/runtime/graphql/typings.d.ts +3 -3
- package/lib/service/worker/runtime/graphql/utils/cacheControl.js +2 -1
- package/lib/service/worker/runtime/graphql/utils/error.js +10 -9
- package/lib/service/worker/runtime/graphql/utils/pathname.js +3 -2
- package/lib/service/worker/runtime/graphql/utils/translations.d.ts +1 -1
- package/lib/service/worker/runtime/graphql/utils/translations.js +7 -4
- package/lib/service/worker/runtime/http/index.d.ts +2 -2
- package/lib/service/worker/runtime/http/index.js +22 -20
- package/lib/service/worker/runtime/http/middlewares/context.js +7 -5
- package/lib/service/worker/runtime/http/middlewares/error.js +6 -9
- package/lib/service/worker/runtime/http/middlewares/rateLimit.js +1 -1
- package/lib/service/worker/runtime/http/middlewares/setCookie.js +5 -5
- package/lib/service/worker/runtime/http/middlewares/settings.d.ts +1 -1
- package/lib/service/worker/runtime/http/middlewares/settings.js +13 -9
- package/lib/service/worker/runtime/http/middlewares/timings.js +3 -3
- package/lib/service/worker/runtime/http/router.js +3 -2
- package/lib/service/worker/runtime/http/routes.js +8 -5
- package/lib/service/worker/runtime/method.d.ts +2 -2
- package/lib/service/worker/runtime/method.js +1 -1
- package/lib/service/worker/runtime/statusTrack.d.ts +1 -1
- package/lib/service/worker/runtime/statusTrack.js +10 -5
- package/lib/service/worker/runtime/typings.d.ts +10 -10
- package/lib/service/worker/runtime/utils/compose.d.ts +2 -2
- package/lib/service/worker/runtime/utils/compose.js +4 -2
- package/lib/service/worker/runtime/utils/context.d.ts +2 -2
- package/lib/service/worker/runtime/utils/context.js +5 -4
- package/lib/service/worker/runtime/utils/recorder.js +1 -1
- package/lib/service/worker/runtime/utils/toArray.js +2 -1
- package/lib/tracing/UserLandTracer.js +3 -2
- package/lib/tracing/errorReporting/ErrorReport.js +13 -13
- package/lib/tracing/index.js +1 -1
- package/lib/tracing/utils.js +5 -4
- package/lib/utils/MineWinsConflictsResolver.d.ts +4 -4
- package/lib/utils/MineWinsConflictsResolver.js +10 -10
- package/lib/utils/app.js +39 -23
- package/lib/utils/appsStaleIfError.d.ts +1 -0
- package/lib/utils/appsStaleIfError.js +17 -9
- package/lib/utils/billingOptions.js +2 -1
- package/lib/utils/binding.js +4 -2
- package/lib/utils/domain.js +1 -1
- package/lib/utils/error.js +5 -4
- package/lib/utils/index.js +6 -2
- package/lib/utils/log.js +3 -2
- package/lib/utils/message.js +8 -5
- package/lib/utils/renameBy.js +2 -1
- package/lib/utils/retry.js +8 -6
- package/lib/utils/status.js +2 -1
- package/lib/utils/tenant.js +4 -2
- package/lib/utils/time.d.ts +1 -1
- package/lib/utils/time.js +23 -14
- package/package.json +27 -5
- package/lib/utils/buildFullPath.d.ts +0 -11
- package/lib/utils/buildFullPath.js +0 -54
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BILLING_TYPE = exports.isFreeBillingOptions = void 0;
|
|
4
|
-
|
|
4
|
+
const isFreeBillingOptions = (billingOptions) => billingOptions.type === BILLING_TYPE.FREE;
|
|
5
|
+
exports.isFreeBillingOptions = isFreeBillingOptions;
|
|
5
6
|
var BILLING_TYPE;
|
|
6
7
|
(function (BILLING_TYPE) {
|
|
7
8
|
BILLING_TYPE["FREE"] = "free";
|
package/lib/utils/binding.js
CHANGED
|
@@ -6,7 +6,7 @@ var BindingHeaderFormat;
|
|
|
6
6
|
BindingHeaderFormat["webframework0"] = "v0+webframework";
|
|
7
7
|
BindingHeaderFormat["kuberouter0"] = "v0+kuberouter";
|
|
8
8
|
})(BindingHeaderFormat || (BindingHeaderFormat = {}));
|
|
9
|
-
|
|
9
|
+
const formatBindingHeaderValue = (binding, format = BindingHeaderFormat.webframework0) => {
|
|
10
10
|
if (format === BindingHeaderFormat.webframework0) {
|
|
11
11
|
const jsonString = JSON.stringify(binding);
|
|
12
12
|
return Buffer.from(jsonString, 'utf8').toString('base64');
|
|
@@ -22,7 +22,8 @@ exports.formatBindingHeaderValue = (binding, format = BindingHeaderFormat.webfra
|
|
|
22
22
|
}
|
|
23
23
|
throw new Error(`Unkown binding format: ${format}`);
|
|
24
24
|
};
|
|
25
|
-
exports.
|
|
25
|
+
exports.formatBindingHeaderValue = formatBindingHeaderValue;
|
|
26
|
+
const parseBindingHeaderValue = (value) => {
|
|
26
27
|
if (value[0] === '0' && value[1] === ',') {
|
|
27
28
|
// v0+kuberouter
|
|
28
29
|
const [, id, rootPath, locale, currency] = value.split(',');
|
|
@@ -37,3 +38,4 @@ exports.parseBindingHeaderValue = (value) => {
|
|
|
37
38
|
const jsonString = Buffer.from(value, 'base64').toString('utf8');
|
|
38
39
|
return JSON.parse(jsonString);
|
|
39
40
|
};
|
|
41
|
+
exports.parseBindingHeaderValue = parseBindingHeaderValue;
|
package/lib/utils/domain.js
CHANGED
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PUBLIC_DOMAINS = void 0;
|
|
4
4
|
const ramda_1 = require("ramda");
|
|
5
5
|
const VTEX_PUBLIC_ENDPOINT = process.env.VTEX_PUBLIC_ENDPOINT || 'myvtex.com';
|
|
6
|
-
exports.PUBLIC_DOMAINS = ramda_1.uniq([VTEX_PUBLIC_ENDPOINT, 'myvtex.com', 'mygocommerce.com', 'vtexsmb.com']);
|
|
6
|
+
exports.PUBLIC_DOMAINS = (0, ramda_1.uniq)([VTEX_PUBLIC_ENDPOINT, 'myvtex.com', 'mygocommerce.com', 'vtexsmb.com']);
|
package/lib/utils/error.js
CHANGED
|
@@ -6,7 +6,7 @@ const ramda_1 = require("ramda");
|
|
|
6
6
|
exports.PICKED_AXIOS_PROPS = ['baseURL', 'cacheable', 'data', 'finished', 'headers', 'method', 'timeout', 'status', 'path', 'url', 'metric', 'inflightKey', 'forceMaxAge', 'params', 'responseType'];
|
|
7
7
|
exports.SENSITIVE_EXCEPTION_FIELDS = ['config', 'request', 'stack'];
|
|
8
8
|
const MAX_ERROR_STRING_LENGTH = process.env.MAX_ERROR_STRING_LENGTH ? parseInt(process.env.MAX_ERROR_STRING_LENGTH, 10) : 8 * 1024;
|
|
9
|
-
const findCaseInsensitive = (target, set) => ramda_1.find(t => t.toLocaleLowerCase() === target, set);
|
|
9
|
+
const findCaseInsensitive = (target, set) => (0, ramda_1.find)(t => t.toLocaleLowerCase() === target, set);
|
|
10
10
|
const destroyCircular = (from, seen) => {
|
|
11
11
|
const to = Array.isArray(from) ? [] : {};
|
|
12
12
|
seen.push(from);
|
|
@@ -53,10 +53,10 @@ const destroyCircular = (from, seen) => {
|
|
|
53
53
|
];
|
|
54
54
|
for (const property of axiosProperties) {
|
|
55
55
|
if (to[property] != null && typeof to[property] === 'object') {
|
|
56
|
-
to[property] = ramda_1.pick(exports.PICKED_AXIOS_PROPS, to[property]);
|
|
56
|
+
to[property] = (0, ramda_1.pick)(exports.PICKED_AXIOS_PROPS, to[property]);
|
|
57
57
|
const headers = to[property] && to[property].headers;
|
|
58
58
|
if (headers) {
|
|
59
|
-
const headerNames = ramda_1.keys(headers);
|
|
59
|
+
const headerNames = (0, ramda_1.keys)(headers);
|
|
60
60
|
const authorization = findCaseInsensitive('authorization', headerNames);
|
|
61
61
|
if (!!authorization) {
|
|
62
62
|
delete headers[authorization];
|
|
@@ -82,7 +82,7 @@ const destroyCircular = (from, seen) => {
|
|
|
82
82
|
*
|
|
83
83
|
* @param value an Error instance
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
const cleanError = (value) => {
|
|
86
86
|
if (typeof value === 'object') {
|
|
87
87
|
return destroyCircular(value, []);
|
|
88
88
|
}
|
|
@@ -93,3 +93,4 @@ exports.cleanError = (value) => {
|
|
|
93
93
|
}
|
|
94
94
|
return value;
|
|
95
95
|
};
|
|
96
|
+
exports.cleanError = cleanError;
|
package/lib/utils/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./app"), exports);
|
package/lib/utils/log.js
CHANGED
|
@@ -16,6 +16,7 @@ const SENSITIVE_FIELDS = [
|
|
|
16
16
|
'x-vtex-credential',
|
|
17
17
|
'x-vtex-session',
|
|
18
18
|
];
|
|
19
|
-
|
|
20
|
-
return json_1.cleanJson(log, SENSITIVE_FIELDS);
|
|
19
|
+
const cleanLog = (log) => {
|
|
20
|
+
return (0, json_1.cleanJson)(log, SENSITIVE_FIELDS);
|
|
21
21
|
};
|
|
22
|
+
exports.cleanLog = cleanLog;
|
package/lib/utils/message.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.removeProviderFromId = exports.parseIOMessageId = exports.providerFromMessage = exports.PROVIDER_SPACER = void 0;
|
|
4
4
|
exports.PROVIDER_SPACER = '::';
|
|
5
|
-
|
|
6
|
-
const { provider } = exports.parseIOMessageId(message);
|
|
5
|
+
const providerFromMessage = (message) => {
|
|
6
|
+
const { provider } = (0, exports.parseIOMessageId)(message);
|
|
7
7
|
return provider || 'unknown';
|
|
8
8
|
};
|
|
9
|
-
exports.
|
|
9
|
+
exports.providerFromMessage = providerFromMessage;
|
|
10
|
+
const parseIOMessageId = ({ id }) => {
|
|
10
11
|
const splitted = id.split(exports.PROVIDER_SPACER);
|
|
11
12
|
if (splitted.length === 2) {
|
|
12
13
|
return {
|
|
@@ -18,7 +19,9 @@ exports.parseIOMessageId = ({ id }) => {
|
|
|
18
19
|
locator: splitted[0],
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
|
-
exports.
|
|
22
|
+
exports.parseIOMessageId = parseIOMessageId;
|
|
23
|
+
const removeProviderFromId = (message) => ({
|
|
22
24
|
...message,
|
|
23
|
-
id: exports.parseIOMessageId(message).locator,
|
|
25
|
+
id: (0, exports.parseIOMessageId)(message).locator,
|
|
24
26
|
});
|
|
27
|
+
exports.removeProviderFromId = removeProviderFromId;
|
package/lib/utils/renameBy.js
CHANGED
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renameBy = void 0;
|
|
4
4
|
const ramda_1 = require("ramda");
|
|
5
|
-
|
|
5
|
+
const renameBy = (fn, obj) => (0, ramda_1.compose)(ramda_1.fromPairs, (0, ramda_1.map)(([key, val]) => [fn(key), val]), ramda_1.toPairs)(obj);
|
|
6
|
+
exports.renameBy = renameBy;
|
package/lib/utils/retry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAbortedOrNetworkErrorOrRouterTimeout = exports.isNetworkErrorOrRouterTimeout = exports.TIMEOUT_CODE = void 0;
|
|
3
|
+
exports.exponentialDelay = exports.isNetworkOrIdempotentRequestError = exports.isAbortedOrNetworkErrorOrRouterTimeout = exports.isNetworkErrorOrRouterTimeout = exports.TIMEOUT_CODE = void 0;
|
|
4
4
|
const axios_retry_1 = require("axios-retry");
|
|
5
5
|
exports.TIMEOUT_CODE = 'ProxyTimeout';
|
|
6
6
|
const printLabel = (e, message) => {
|
|
@@ -9,25 +9,27 @@ const printLabel = (e, message) => {
|
|
|
9
9
|
}
|
|
10
10
|
console.warn(e.config.label, message);
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
if (axios_retry_1.isNetworkOrIdempotentRequestError(e)) {
|
|
12
|
+
const isNetworkErrorOrRouterTimeout = (e) => {
|
|
13
|
+
if ((0, axios_retry_1.isNetworkOrIdempotentRequestError)(e)) {
|
|
14
14
|
printLabel(e, 'Retry from network error');
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
|
-
if (e && axios_retry_1.isSafeRequestError(e) && e.response && e.response.data && e.response.data.code === exports.TIMEOUT_CODE) {
|
|
17
|
+
if (e && (0, axios_retry_1.isSafeRequestError)(e) && e.response && e.response.data && e.response.data.code === exports.TIMEOUT_CODE) {
|
|
18
18
|
printLabel(e, 'Retry from timeout');
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
21
|
return false;
|
|
22
22
|
};
|
|
23
|
+
exports.isNetworkErrorOrRouterTimeout = isNetworkErrorOrRouterTimeout;
|
|
23
24
|
// Retry on timeout from our end
|
|
24
|
-
|
|
25
|
+
const isAbortedOrNetworkErrorOrRouterTimeout = (e) => {
|
|
25
26
|
if (e && e.code === 'ECONNABORTED') {
|
|
26
27
|
printLabel(e, 'Retry from abort');
|
|
27
28
|
return true;
|
|
28
29
|
}
|
|
29
|
-
return exports.isNetworkErrorOrRouterTimeout(e);
|
|
30
|
+
return (0, exports.isNetworkErrorOrRouterTimeout)(e);
|
|
30
31
|
};
|
|
32
|
+
exports.isAbortedOrNetworkErrorOrRouterTimeout = isAbortedOrNetworkErrorOrRouterTimeout;
|
|
31
33
|
var axios_retry_2 = require("axios-retry");
|
|
32
34
|
Object.defineProperty(exports, "isNetworkOrIdempotentRequestError", { enumerable: true, get: function () { return axios_retry_2.isNetworkOrIdempotentRequestError; } });
|
|
33
35
|
Object.defineProperty(exports, "exponentialDelay", { enumerable: true, get: function () { return axios_retry_2.exponentialDelay; } });
|
package/lib/utils/status.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.statusLabel = void 0;
|
|
4
|
-
|
|
4
|
+
const statusLabel = (status) => {
|
|
5
5
|
if (status >= 500) {
|
|
6
6
|
return 'error';
|
|
7
7
|
}
|
|
@@ -10,3 +10,4 @@ exports.statusLabel = (status) => {
|
|
|
10
10
|
}
|
|
11
11
|
return `${Math.floor(status / 100)}xx`;
|
|
12
12
|
};
|
|
13
|
+
exports.statusLabel = statusLabel;
|
package/lib/utils/tenant.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseTenantHeaderValue = exports.formatTenantHeaderValue = void 0;
|
|
4
|
-
|
|
5
|
-
exports.
|
|
4
|
+
const formatTenantHeaderValue = (tenant) => tenant.locale;
|
|
5
|
+
exports.formatTenantHeaderValue = formatTenantHeaderValue;
|
|
6
|
+
const parseTenantHeaderValue = (value) => ({
|
|
6
7
|
locale: value,
|
|
7
8
|
});
|
|
9
|
+
exports.parseTenantHeaderValue = parseTenantHeaderValue;
|
package/lib/utils/time.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const hrToNano: ([seconds, nanoseconds]: [number, number]) => num
|
|
|
8
8
|
export declare const formatNano: (nanoseconds: number) => string;
|
|
9
9
|
export declare const reduceHrToNano: (values: import("ramda").List<[number, number]>) => number;
|
|
10
10
|
export declare const shrinkTimings: (name: string) => string;
|
|
11
|
-
|
|
11
|
+
type TimingFormat = ReturnType<typeof parseTimingName>;
|
|
12
12
|
export declare const formatTimingName: ({ hopNumber, target, source }: TimingFormat) => string;
|
|
13
13
|
export declare const parseTimingName: (timing: string | undefined) => {
|
|
14
14
|
hopNumber: number | null;
|
package/lib/utils/time.js
CHANGED
|
@@ -3,19 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.timerForEvents = exports.timer = exports.reduceTimings = exports.parseTimingName = exports.formatTimingName = exports.shrinkTimings = exports.reduceHrToNano = exports.formatNano = exports.hrToNano = exports.nanosecondsToSeconds = exports.hrToMillisFloat = exports.hrToMillis = void 0;
|
|
4
4
|
const ramda_1 = require("ramda");
|
|
5
5
|
const logger_1 = require("../service/logger");
|
|
6
|
-
|
|
7
|
-
exports.
|
|
6
|
+
const hrToMillis = ([seconds, nanoseconds]) => Math.round((seconds * 1e3) + (nanoseconds / 1e6));
|
|
7
|
+
exports.hrToMillis = hrToMillis;
|
|
8
|
+
const hrToMillisFloat = ([seconds, nanoseconds]) => {
|
|
8
9
|
return (seconds * 1e3) + (nanoseconds / 1e6);
|
|
9
10
|
};
|
|
10
|
-
exports.
|
|
11
|
+
exports.hrToMillisFloat = hrToMillisFloat;
|
|
12
|
+
const nanosecondsToSeconds = (nanoseconds) => {
|
|
11
13
|
return nanoseconds / 1e9;
|
|
12
14
|
};
|
|
13
|
-
exports.
|
|
14
|
-
|
|
15
|
-
exports.
|
|
16
|
-
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
15
|
+
exports.nanosecondsToSeconds = nanosecondsToSeconds;
|
|
16
|
+
const hrToNano = ([seconds, nanoseconds]) => seconds * 1e9 + nanoseconds;
|
|
17
|
+
exports.hrToNano = hrToNano;
|
|
18
|
+
const formatNano = (nanoseconds) => `${(nanoseconds / 1e9).toFixed(0)}s ${((nanoseconds / 1e6) % 1e3).toFixed(0)}ms`;
|
|
19
|
+
exports.formatNano = formatNano;
|
|
20
|
+
exports.reduceHrToNano = (0, ramda_1.reduce)((acc, hr) => acc + (0, exports.hrToNano)(hr), 0);
|
|
21
|
+
const shrinkTimings = (name) => name.replace(/graphql/g, 'gql').replace(/server/g, 'srv');
|
|
22
|
+
exports.shrinkTimings = shrinkTimings;
|
|
23
|
+
const formatTimingName = ({ hopNumber, target, source }) => `${Number.isNaN(hopNumber) ? '' : hopNumber}.${source || ''}#${target || ''}`;
|
|
24
|
+
exports.formatTimingName = formatTimingName;
|
|
25
|
+
const parseTimingName = (timing) => {
|
|
19
26
|
const [hopNumber, sourceAndTarget] = timing ? timing.split('.') : [null, null];
|
|
20
27
|
const [source, target] = sourceAndTarget ? sourceAndTarget.split('#') : [null, null];
|
|
21
28
|
return {
|
|
@@ -24,7 +31,9 @@ exports.parseTimingName = (timing) => {
|
|
|
24
31
|
target,
|
|
25
32
|
};
|
|
26
33
|
};
|
|
27
|
-
exports.
|
|
34
|
+
exports.parseTimingName = parseTimingName;
|
|
35
|
+
const reduceTimings = (timingsObj) => (0, ramda_1.compose)((0, ramda_1.reduce)((acc, [key, dur]) => `${key};dur=${dur}, ${acc}`, ''), ramda_1.toPairs)(timingsObj);
|
|
36
|
+
exports.reduceTimings = reduceTimings;
|
|
28
37
|
function recordTimings(start, name, timings, middlewareMetrics, success) {
|
|
29
38
|
// Capture the total amount of time spent in this middleware, which includes following middlewares
|
|
30
39
|
const end = process.hrtime(start);
|
|
@@ -44,9 +53,9 @@ function recordTimings(start, name, timings, middlewareMetrics, success) {
|
|
|
44
53
|
metrics.batch(label, success ? elapsed : undefined, { success: success ? 1 : 0 });
|
|
45
54
|
// This middleware has added it's own metrics
|
|
46
55
|
// Just add them to `timings` scoped by the middleware's name and batch them
|
|
47
|
-
const middlewareMetricsKeys = ramda_1.keys(middlewareMetrics);
|
|
56
|
+
const middlewareMetricsKeys = (0, ramda_1.keys)(middlewareMetrics);
|
|
48
57
|
if (success && middlewareMetricsKeys.length > 0) {
|
|
49
|
-
ramda_1.forEach((k) => {
|
|
58
|
+
(0, ramda_1.forEach)((k) => {
|
|
50
59
|
const metricEnd = middlewareMetrics[k];
|
|
51
60
|
// Delete own metrics so next middleware can have empty state but still accumulate metrics batched after `await`
|
|
52
61
|
delete middlewareMetrics[k];
|
|
@@ -61,7 +70,7 @@ function timer(middleware) {
|
|
|
61
70
|
return middleware;
|
|
62
71
|
}
|
|
63
72
|
if (!middleware.name) {
|
|
64
|
-
logger_1.logOnceToDevConsole(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
|
|
73
|
+
(0, logger_1.logOnceToDevConsole)(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
|
|
65
74
|
}
|
|
66
75
|
return async (ctx, next) => {
|
|
67
76
|
if (!ctx.serverTiming) {
|
|
@@ -93,7 +102,7 @@ function timerForEvents(middleware) {
|
|
|
93
102
|
return middleware;
|
|
94
103
|
}
|
|
95
104
|
if (!middleware.name) {
|
|
96
|
-
logger_1.logOnceToDevConsole(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
|
|
105
|
+
(0, logger_1.logOnceToDevConsole)(`Please use a named function as handler for better metrics. ${middleware.toString()}`, logger_1.LogLevel.Warn);
|
|
97
106
|
}
|
|
98
107
|
return async (ctx, next) => {
|
|
99
108
|
if (!ctx.timings) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtex/api",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.49.0",
|
|
4
4
|
"description": "VTEX I/O API client",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"clean": "rimraf lib/",
|
|
13
13
|
"watch": "yarn clean && tsc --watch",
|
|
14
14
|
"build": "yarn clean && tsc",
|
|
15
|
-
"gen": "typescript-json-schema
|
|
15
|
+
"gen": "typescript-json-schema src/responses.ts PublicAppManifest > gen/manifest.schema",
|
|
16
16
|
"test": "jest",
|
|
17
17
|
"lint": "tslint -c tslint.json './src/**/*.ts'",
|
|
18
18
|
"format": "prettier --config ./.prettierrc --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
@@ -49,12 +49,13 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@types/koa": "^2.11.0",
|
|
51
51
|
"@types/koa-compose": "^3.2.3",
|
|
52
|
+
"@vtex/diagnostics-nodejs": "0.1.0-beta.8",
|
|
52
53
|
"@vtex/node-error-report": "^0.0.3",
|
|
53
54
|
"@wry/equality": "^0.1.9",
|
|
54
55
|
"agentkeepalive": "^4.0.2",
|
|
55
56
|
"apollo-server-errors": "^2.2.1",
|
|
56
57
|
"archiver": "^3.0.0",
|
|
57
|
-
"axios": "^
|
|
58
|
+
"axios": "^0.21.1",
|
|
58
59
|
"axios-retry": "^3.1.2",
|
|
59
60
|
"bluebird": "^3.5.4",
|
|
60
61
|
"chalk": "^2.4.2",
|
|
@@ -121,7 +122,28 @@
|
|
|
121
122
|
"tslint-config-vtex": "^2.1.0",
|
|
122
123
|
"tslint-eslint-rules": "^5.4.0",
|
|
123
124
|
"typemoq": "^2.1.0",
|
|
124
|
-
"typescript": "
|
|
125
|
-
"typescript-json-schema": "^0.
|
|
125
|
+
"typescript": "^4.4.4",
|
|
126
|
+
"typescript-json-schema": "^0.52.0"
|
|
127
|
+
},
|
|
128
|
+
"resolutions": {
|
|
129
|
+
"@opentelemetry/core": "1.30.1",
|
|
130
|
+
"@opentelemetry/exporter-metrics-otlp-grpc": "0.57.2",
|
|
131
|
+
"@opentelemetry/exporter-metrics-otlp-http": "0.57.2",
|
|
132
|
+
"@opentelemetry/exporter-logs-otlp-grpc": "0.57.2",
|
|
133
|
+
"@opentelemetry/exporter-logs-otlp-http": "0.57.2",
|
|
134
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "0.57.2",
|
|
135
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.57.2",
|
|
136
|
+
"@opentelemetry/instrumentation": "0.57.2",
|
|
137
|
+
"@opentelemetry/instrumentation-http": "0.57.2",
|
|
138
|
+
"@opentelemetry/instrumentation-grpc": "0.57.2",
|
|
139
|
+
"@opentelemetry/instrumentation-net": "0.43.1",
|
|
140
|
+
"@opentelemetry/propagator-b3": "1.30.1",
|
|
141
|
+
"@opentelemetry/resource-detector-aws": "1.12.0",
|
|
142
|
+
"@opentelemetry/resources": "1.30.1",
|
|
143
|
+
"@opentelemetry/sdk-node": "0.57.2",
|
|
144
|
+
"@opentelemetry/sdk-logs": "0.57.2",
|
|
145
|
+
"@opentelemetry/sdk-metrics": "1.30.1",
|
|
146
|
+
"@opentelemetry/sdk-trace-base": "1.30.1",
|
|
147
|
+
"@opentelemetry/sdk-trace-node": "1.30.1"
|
|
126
148
|
}
|
|
127
149
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
3
|
-
* only when the requestedURL is not already an absolute URL.
|
|
4
|
-
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
5
|
-
*
|
|
6
|
-
* @param {string} baseURL The base URL
|
|
7
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
|
8
|
-
*
|
|
9
|
-
* @returns {string} The combined full path
|
|
10
|
-
*/
|
|
11
|
-
export default function (baseURL?: string, requestedURL?: string, allowAbsoluteUrls?: boolean): string | undefined;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This module is part of the Axios library.
|
|
3
|
-
// It is used to build a full URL by combining a base URL with a relative URL.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
// It is originally not intended to be used directly, but rather as a utility function within the Axios library.
|
|
6
|
-
// Since Axios 1.0, this function is not exported by default, and the team does not recommend using it directly,
|
|
7
|
-
// as it may not be available in future versions.
|
|
8
|
-
// The function takes a base URL and a relative URL as input, and returns the full URL.
|
|
9
|
-
// It handles both absolute and relative URLs, and ensures that the resulting URL is properly formatted.
|
|
10
|
-
// It is used internally by Axios to construct the full URL for HTTP requests.
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
13
|
-
* only when the requestedURL is not already an absolute URL.
|
|
14
|
-
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
15
|
-
*
|
|
16
|
-
* @param {string} baseURL The base URL
|
|
17
|
-
* @param {string} requestedURL Absolute or relative URL to combine
|
|
18
|
-
*
|
|
19
|
-
* @returns {string} The combined full path
|
|
20
|
-
*/
|
|
21
|
-
function default_1(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
22
|
-
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
23
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
|
|
24
|
-
return combineURLs(baseURL, requestedURL);
|
|
25
|
-
}
|
|
26
|
-
return requestedURL;
|
|
27
|
-
}
|
|
28
|
-
exports.default = default_1;
|
|
29
|
-
/**
|
|
30
|
-
* Determines whether the specified URL is absolute
|
|
31
|
-
*
|
|
32
|
-
* @param {string} url The URL to test
|
|
33
|
-
*
|
|
34
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
35
|
-
*/
|
|
36
|
-
function isAbsoluteURL(url) {
|
|
37
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
38
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
39
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
|
40
|
-
return !!url && /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Creates a new URL by combining the specified URLs
|
|
44
|
-
*
|
|
45
|
-
* @param {string} baseURL The base URL
|
|
46
|
-
* @param {string} relativeURL The relative URL
|
|
47
|
-
*
|
|
48
|
-
* @returns {string} The combined URL
|
|
49
|
-
*/
|
|
50
|
-
function combineURLs(baseURL, relativeURL) {
|
|
51
|
-
return relativeURL && baseURL
|
|
52
|
-
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
53
|
-
: baseURL;
|
|
54
|
-
}
|