@vtex/api 6.48.1-beta.2 → 6.48.1-beta.3
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/lib/HttpClient/GraphQLClient.d.ts +1 -1
- package/lib/HttpClient/HttpClient.d.ts +2 -3
- package/lib/HttpClient/HttpClient.js +14 -14
- package/lib/HttpClient/agents.d.ts +2 -5
- package/lib/HttpClient/agents.js +4 -10
- package/lib/HttpClient/index.js +2 -7
- package/lib/HttpClient/middlewares/cache.d.ts +1 -1
- package/lib/HttpClient/middlewares/cache.js +36 -38
- package/lib/HttpClient/middlewares/cancellationToken.d.ts +1 -1
- package/lib/HttpClient/middlewares/cancellationToken.js +1 -2
- package/lib/HttpClient/middlewares/inflight.d.ts +1 -1
- package/lib/HttpClient/middlewares/inflight.js +3 -6
- package/lib/HttpClient/middlewares/memoization.d.ts +1 -1
- package/lib/HttpClient/middlewares/memoization.js +8 -9
- package/lib/HttpClient/middlewares/metrics.js +7 -8
- package/lib/HttpClient/middlewares/notFound.d.ts +1 -1
- package/lib/HttpClient/middlewares/notFound.js +2 -4
- package/lib/HttpClient/middlewares/recorder.js +1 -2
- 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 +10 -13
- package/lib/HttpClient/middlewares/request/setupAxios/index.d.ts +1 -0
- package/lib/HttpClient/middlewares/request/setupAxios/index.js +4 -5
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.js +5 -6
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/index.js +0 -1
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/index.js +8 -8
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +8 -10
- package/lib/HttpClient/middlewares/tracing.js +10 -11
- package/lib/HttpClient/typings.d.ts +2 -2
- package/lib/caches/DiskCache.js +2 -2
- package/lib/caches/LRUCache.d.ts +2 -2
- package/lib/caches/LRUDiskCache.d.ts +1 -1
- package/lib/caches/LRUDiskCache.js +2 -2
- package/lib/caches/MultilayeredCache.d.ts +2 -2
- package/lib/caches/MultilayeredCache.js +6 -6
- package/lib/caches/index.js +2 -6
- 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 +2 -6
- package/lib/clients/external/ID.d.ts +4 -4
- package/lib/clients/external/PaymentProvider.d.ts +2 -2
- package/lib/clients/external/index.js +2 -6
- package/lib/clients/index.js +2 -6
- package/lib/clients/infra/Apps.d.ts +27 -32
- package/lib/clients/infra/Apps.js +16 -16
- package/lib/clients/infra/Assets.d.ts +5 -6
- 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 +17 -23
- package/lib/clients/infra/Registry.js +3 -3
- 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 +14 -15
- package/lib/clients/infra/VBase.js +2 -2
- package/lib/clients/infra/Workspaces.d.ts +7 -7
- package/lib/clients/infra/index.js +2 -6
- 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 +2 -6
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +1 -1
- package/lib/errors/ResolverError.js +1 -1
- package/lib/errors/index.js +2 -6
- package/lib/index.js +2 -6
- 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 +6 -7
- package/lib/service/loaders.js +6 -8
- package/lib/service/logger/console.js +4 -7
- package/lib/service/logger/index.js +2 -6
- package/lib/service/logger/logger.js +2 -2
- package/lib/service/logger/metricsLogger.js +10 -10
- package/lib/service/master.js +6 -7
- package/lib/service/metrics/requestMetricsMiddleware.js +13 -14
- package/lib/service/tracing/TracerSingleton.js +9 -9
- package/lib/service/tracing/metrics/MetricNames.js +12 -12
- package/lib/service/tracing/metrics/instruments.js +7 -14
- package/lib/service/tracing/metrics/measurers/EventLoopLagMeasurer.js +5 -5
- package/lib/service/tracing/tracingMiddlewares.js +15 -18
- package/lib/service/worker/index.js +23 -24
- package/lib/service/worker/listeners.js +1 -2
- package/lib/service/worker/runtime/Service.js +1 -1
- package/lib/service/worker/runtime/builtIn/handlers.js +3 -6
- package/lib/service/worker/runtime/builtIn/middlewares.js +3 -5
- package/lib/service/worker/runtime/events/index.d.ts +1 -1
- package/lib/service/worker/runtime/events/index.js +10 -11
- package/lib/service/worker/runtime/events/middlewares/body.js +2 -2
- package/lib/service/worker/runtime/events/middlewares/context.js +1 -1
- package/lib/service/worker/runtime/events/router.js +2 -3
- package/lib/service/worker/runtime/graphql/index.js +7 -8
- package/lib/service/worker/runtime/graphql/middlewares/error.js +5 -5
- package/lib/service/worker/runtime/graphql/middlewares/query.js +6 -7
- package/lib/service/worker/runtime/graphql/middlewares/response.js +1 -1
- package/lib/service/worker/runtime/graphql/middlewares/run.js +2 -3
- package/lib/service/worker/runtime/graphql/middlewares/updateSchema.js +3 -4
- 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 +7 -8
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.d.ts +2 -2
- package/lib/service/worker/runtime/graphql/schema/messagesLoaderV2.js +3 -4
- 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 +1 -2
- 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 +1 -2
- package/lib/service/worker/runtime/graphql/utils/error.js +9 -10
- package/lib/service/worker/runtime/graphql/utils/pathname.js +2 -3
- package/lib/service/worker/runtime/graphql/utils/translations.d.ts +1 -1
- package/lib/service/worker/runtime/graphql/utils/translations.js +4 -7
- package/lib/service/worker/runtime/http/index.d.ts +2 -2
- package/lib/service/worker/runtime/http/index.js +20 -22
- package/lib/service/worker/runtime/http/middlewares/context.js +5 -7
- package/lib/service/worker/runtime/http/middlewares/error.js +1 -1
- 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 +9 -13
- package/lib/service/worker/runtime/http/middlewares/timings.js +3 -3
- package/lib/service/worker/runtime/http/router.js +2 -3
- package/lib/service/worker/runtime/http/routes.js +5 -8
- 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 +5 -10
- 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 +2 -4
- package/lib/service/worker/runtime/utils/context.d.ts +2 -2
- package/lib/service/worker/runtime/utils/context.js +4 -5
- package/lib/service/worker/runtime/utils/recorder.js +1 -1
- package/lib/service/worker/runtime/utils/toArray.js +1 -2
- package/lib/tracing/UserLandTracer.js +2 -3
- package/lib/tracing/errorReporting/ErrorReport.js +13 -13
- package/lib/tracing/index.js +1 -1
- package/lib/tracing/utils.js +4 -5
- package/lib/utils/MineWinsConflictsResolver.d.ts +4 -4
- package/lib/utils/MineWinsConflictsResolver.js +10 -10
- package/lib/utils/app.js +23 -39
- package/lib/utils/appsStaleIfError.d.ts +0 -1
- package/lib/utils/appsStaleIfError.js +9 -17
- package/lib/utils/billingOptions.js +1 -2
- package/lib/utils/binding.js +2 -4
- package/lib/utils/buildFullPath.d.ts +11 -0
- package/lib/utils/buildFullPath.js +54 -0
- package/lib/utils/domain.js +1 -1
- package/lib/utils/error.js +4 -5
- package/lib/utils/index.js +2 -6
- package/lib/utils/log.js +2 -3
- package/lib/utils/message.js +5 -8
- package/lib/utils/renameBy.js +1 -2
- package/lib/utils/retry.js +6 -8
- package/lib/utils/status.js +1 -2
- package/lib/utils/tenant.js +2 -4
- package/lib/utils/time.d.ts +1 -1
- package/lib/utils/time.js +14 -23
- package/package.json +2 -2
|
@@ -4,19 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.requestMiddleware = exports.routerCacheMiddleware = exports.defaultsMiddleware = void 0;
|
|
7
|
-
const buildFullPath_1 = __importDefault(require("
|
|
7
|
+
const buildFullPath_1 = __importDefault(require("../../../utils/buildFullPath"));
|
|
8
8
|
const qs_1 = require("qs");
|
|
9
9
|
const ramda_1 = require("ramda");
|
|
10
10
|
const Tags_1 = require("../../../tracing/Tags");
|
|
11
11
|
const renameBy_1 = require("../../../utils/renameBy");
|
|
12
12
|
const setupAxios_1 = require("./setupAxios");
|
|
13
|
-
const http =
|
|
13
|
+
const http = setupAxios_1.getConfiguredAxios();
|
|
14
14
|
const paramsSerializer = (params) => {
|
|
15
|
-
return
|
|
15
|
+
return qs_1.stringify(params, { arrayFormat: 'repeat' });
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
exports.defaultsMiddleware = ({ baseURL, rawHeaders, params, timeout, retries, verbose, exponentialTimeoutCoefficient, initialBackoffDelay, exponentialBackoffCoefficient, httpsAgent }) => {
|
|
18
18
|
const countByMetric = {};
|
|
19
|
-
const headers =
|
|
19
|
+
const headers = renameBy_1.renameBy(ramda_1.toLower, rawHeaders);
|
|
20
20
|
return (ctx, next) => {
|
|
21
21
|
var _a, _b, _c;
|
|
22
22
|
ctx.config = {
|
|
@@ -33,7 +33,7 @@ const defaultsMiddleware = ({ baseURL, rawHeaders, params, timeout, retries, ver
|
|
|
33
33
|
...ctx.config,
|
|
34
34
|
headers: {
|
|
35
35
|
...headers,
|
|
36
|
-
...
|
|
36
|
+
...renameBy_1.renameBy(ramda_1.toLower, ctx.config.headers),
|
|
37
37
|
},
|
|
38
38
|
params: {
|
|
39
39
|
...params,
|
|
@@ -50,7 +50,7 @@ const defaultsMiddleware = ({ baseURL, rawHeaders, params, timeout, retries, ver
|
|
|
50
50
|
}
|
|
51
51
|
if ((_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.isSampled) {
|
|
52
52
|
const { config } = ctx;
|
|
53
|
-
const fullUrl =
|
|
53
|
+
const fullUrl = buildFullPath_1.default(config.baseURL, http.getUri(config));
|
|
54
54
|
(_c = (_b = ctx.tracing) === null || _b === void 0 ? void 0 : _b.rootSpan) === null || _c === void 0 ? void 0 : _c.addTags({
|
|
55
55
|
[Tags_1.OpentracingTags.HTTP_METHOD]: config.method || 'get',
|
|
56
56
|
[Tags_1.OpentracingTags.HTTP_URL]: fullUrl,
|
|
@@ -59,17 +59,16 @@ const defaultsMiddleware = ({ baseURL, rawHeaders, params, timeout, retries, ver
|
|
|
59
59
|
return next();
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
exports.defaultsMiddleware = defaultsMiddleware;
|
|
63
62
|
const ROUTER_CACHE_KEY = 'x-router-cache';
|
|
64
63
|
const ROUTER_CACHE_HIT = 'HIT';
|
|
65
64
|
const ROUTER_CACHE_REVALIDATED = 'REVALIDATED';
|
|
66
|
-
|
|
65
|
+
exports.routerCacheMiddleware = async (ctx, next) => {
|
|
67
66
|
var _a, _b, _c, _d, _e;
|
|
68
67
|
await next();
|
|
69
68
|
const routerCacheHit = (_b = (_a = ctx.response) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b[ROUTER_CACHE_KEY];
|
|
70
69
|
const status = (_c = ctx.response) === null || _c === void 0 ? void 0 : _c.status;
|
|
71
70
|
if (routerCacheHit) {
|
|
72
|
-
(_e = (_d = ctx.tracing) === null || _d === void 0 ? void 0 : _d.rootSpan) === null || _e === void 0 ? void 0 : _e.setTag("http.cache.router" /*
|
|
71
|
+
(_e = (_d = ctx.tracing) === null || _d === void 0 ? void 0 : _d.rootSpan) === null || _e === void 0 ? void 0 : _e.setTag("http.cache.router" /* HTTP_ROUTER_CACHE_RESULT */, routerCacheHit);
|
|
73
72
|
}
|
|
74
73
|
if (routerCacheHit === ROUTER_CACHE_HIT || (routerCacheHit === ROUTER_CACHE_REVALIDATED && status !== 304)) {
|
|
75
74
|
ctx.cacheHit = {
|
|
@@ -80,9 +79,7 @@ const routerCacheMiddleware = async (ctx, next) => {
|
|
|
80
79
|
};
|
|
81
80
|
}
|
|
82
81
|
};
|
|
83
|
-
exports.
|
|
84
|
-
const requestMiddleware = (limit) => async (ctx, next) => {
|
|
82
|
+
exports.requestMiddleware = (limit) => async (ctx, next) => {
|
|
85
83
|
const makeRequest = () => http.request(ctx.config);
|
|
86
84
|
ctx.response = await (limit ? limit(makeRequest) : makeRequest());
|
|
87
85
|
};
|
|
88
|
-
exports.requestMiddleware = requestMiddleware;
|
|
@@ -7,16 +7,15 @@ exports.getConfiguredAxios = void 0;
|
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const HttpAgentSingleton_1 = require("../HttpAgentSingleton");
|
|
9
9
|
const interceptors_1 = require("./interceptors");
|
|
10
|
-
|
|
10
|
+
exports.getConfiguredAxios = () => {
|
|
11
11
|
const httpAgent = HttpAgentSingleton_1.HttpAgentSingleton.getHttpAgent();
|
|
12
12
|
const http = axios_1.default.create({
|
|
13
13
|
httpAgent,
|
|
14
14
|
});
|
|
15
|
-
|
|
15
|
+
interceptors_1.addTracingPreRequestInterceptor(http);
|
|
16
16
|
// Do not change this order, otherwise each request span will
|
|
17
17
|
// wait all retries to finish before finishing the span
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
interceptors_1.addTracingResponseInterceptor(http);
|
|
19
|
+
interceptors_1.addExponentialBackoffResponseInterceptor(http);
|
|
20
20
|
return http;
|
|
21
21
|
};
|
|
22
|
-
exports.getConfiguredAxios = getConfiguredAxios;
|
|
@@ -29,7 +29,7 @@ const onResponseError = (http) => (error) => {
|
|
|
29
29
|
}
|
|
30
30
|
const { initialBackoffDelay = 200, exponentialBackoffCoefficient = 2, exponentialTimeoutCoefficient, } = config;
|
|
31
31
|
const retryCount = config.retryCount || 0;
|
|
32
|
-
const shouldRetry =
|
|
32
|
+
const shouldRetry = retry_1.isAbortedOrNetworkErrorOrRouterTimeout(error) && retryCount < config.retries;
|
|
33
33
|
if (shouldRetry) {
|
|
34
34
|
config.retryCount = retryCount + 1;
|
|
35
35
|
const delay = exponentialDelay(initialBackoffDelay, exponentialBackoffCoefficient, config.retryCount);
|
|
@@ -40,16 +40,15 @@ const onResponseError = (http) => (error) => {
|
|
|
40
40
|
? config.timeout * exponentialTimeoutCoefficient
|
|
41
41
|
: config.timeout;
|
|
42
42
|
config.transformRequest = [data => data];
|
|
43
|
-
(_b = (_a = config.tracing) === null || _a === void 0 ? void 0 : _a.rootSpan) === null || _b === void 0 ? void 0 : _b.log({ event: "setup-request-retry" /*
|
|
43
|
+
(_b = (_a = config.tracing) === null || _a === void 0 ? void 0 : _a.rootSpan) === null || _b === void 0 ? void 0 : _b.log({ event: "setup-request-retry" /* SETUP_REQUEST_RETRY */, ["retry-number" /* RETRY_NUMBER */]: config.retryCount, ["retry-in" /* RETRY_IN */]: delay });
|
|
44
44
|
(_d = (_c = config.tracing) === null || _c === void 0 ? void 0 : _c.rootSpan) === null || _d === void 0 ? void 0 : _d.addTags({
|
|
45
|
-
["http.retry.count" /*
|
|
46
|
-
["http.retry.error.code" /*
|
|
45
|
+
["http.retry.count" /* HTTP_RETRY_COUNT */]: config.retryCount,
|
|
46
|
+
["http.retry.error.code" /* HTTP_RETRY_ERROR_CODE */]: error.code,
|
|
47
47
|
});
|
|
48
48
|
return new Promise(resolve => setTimeout(() => resolve(http(config)), delay));
|
|
49
49
|
}
|
|
50
50
|
return Promise.reject(error);
|
|
51
51
|
};
|
|
52
|
-
|
|
52
|
+
exports.addExponentialBackoffResponseInterceptor = (http) => {
|
|
53
53
|
http.interceptors.response.use(undefined, onResponseError(http));
|
|
54
54
|
};
|
|
55
|
-
exports.addExponentialBackoffResponseInterceptor = addExponentialBackoffResponseInterceptor;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addTracingResponseInterceptor = exports.addTracingPreRequestInterceptor = exports.addExponentialBackoffResponseInterceptor = void 0;
|
|
4
3
|
var exponentialBackoff_1 = require("./exponentialBackoff");
|
|
5
4
|
Object.defineProperty(exports, "addExponentialBackoffResponseInterceptor", { enumerable: true, get: function () { return exponentialBackoff_1.addExponentialBackoffResponseInterceptor; } });
|
|
6
5
|
var tracing_1 = require("./tracing");
|
|
@@ -15,10 +15,10 @@ const preRequestInterceptor = (http) => (config) => {
|
|
|
15
15
|
const spanName = requestSpanNameSuffix ? `${exports.requestSpanPrefix}:${requestSpanNameSuffix}` : exports.requestSpanPrefix;
|
|
16
16
|
const span = rootSpan
|
|
17
17
|
? tracer.startSpan(spanName, {
|
|
18
|
-
references: [
|
|
18
|
+
references: [tracing_1.createSpanReference(rootSpan, SpanReferenceTypes_1.SpanReferenceTypes.CHILD_OF)],
|
|
19
19
|
})
|
|
20
20
|
: tracer.startSpan(spanName);
|
|
21
|
-
|
|
21
|
+
spanSetup_1.injectRequestInfoOnSpan(span, http, config);
|
|
22
22
|
config.tracing.requestSpan = span;
|
|
23
23
|
tracer.inject(span, opentracing_1.FORMAT_HTTP_HEADERS, config.headers);
|
|
24
24
|
return config;
|
|
@@ -29,7 +29,7 @@ const onResponseSuccess = (response) => {
|
|
|
29
29
|
return response;
|
|
30
30
|
}
|
|
31
31
|
const requestSpan = (_b = response.config.tracing) === null || _b === void 0 ? void 0 : _b.requestSpan;
|
|
32
|
-
|
|
32
|
+
spanSetup_1.injectResponseInfoOnSpan(requestSpan, response);
|
|
33
33
|
requestSpan === null || requestSpan === void 0 ? void 0 : requestSpan.finish();
|
|
34
34
|
return response;
|
|
35
35
|
};
|
|
@@ -39,18 +39,18 @@ const onResponseError = (err) => {
|
|
|
39
39
|
return Promise.reject(err);
|
|
40
40
|
}
|
|
41
41
|
const { requestSpan } = err.config.tracing;
|
|
42
|
-
|
|
42
|
+
spanSetup_1.injectResponseInfoOnSpan(requestSpan, err.response);
|
|
43
43
|
tracing_1.ErrorReport.create({ originalError: err }).injectOnSpan(requestSpan, err.config.tracing.logger);
|
|
44
44
|
requestSpan.finish();
|
|
45
45
|
return Promise.reject(err);
|
|
46
46
|
};
|
|
47
|
-
|
|
47
|
+
exports.addTracingPreRequestInterceptor = (http) => {
|
|
48
|
+
// Usando type assertion para compatibilidade com TypeScript 3.9.7
|
|
48
49
|
const requestTracingInterceptor = http.interceptors.request.use(preRequestInterceptor(http), undefined);
|
|
49
50
|
return { requestTracingInterceptor };
|
|
50
51
|
};
|
|
51
|
-
exports.
|
|
52
|
-
|
|
52
|
+
exports.addTracingResponseInterceptor = (http) => {
|
|
53
|
+
// Usando type assertion para compatibilidade com TypeScript 3.9.7
|
|
53
54
|
const responseTracingInterceptor = http.interceptors.response.use(onResponseSuccess, onResponseError);
|
|
54
55
|
return { responseTracingInterceptor };
|
|
55
56
|
};
|
|
56
|
-
exports.addTracingResponseInterceptor = addTracingResponseInterceptor;
|
|
@@ -4,29 +4,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.injectResponseInfoOnSpan = exports.injectRequestInfoOnSpan = void 0;
|
|
7
|
-
const buildFullPath_1 = __importDefault(require("
|
|
7
|
+
const buildFullPath_1 = __importDefault(require("../../../../../../utils/buildFullPath"));
|
|
8
8
|
const constants_1 = require("../../../../../../constants");
|
|
9
9
|
const Tags_1 = require("../../../../../../tracing/Tags");
|
|
10
10
|
const utils_1 = require("../../../../../../tracing/utils");
|
|
11
|
-
|
|
11
|
+
exports.injectRequestInfoOnSpan = (span, http, config) => {
|
|
12
12
|
span === null || span === void 0 ? void 0 : span.addTags({
|
|
13
13
|
[Tags_1.OpentracingTags.SPAN_KIND]: Tags_1.OpentracingTags.SPAN_KIND_RPC_CLIENT,
|
|
14
14
|
[Tags_1.OpentracingTags.HTTP_METHOD]: config.method,
|
|
15
|
-
[Tags_1.OpentracingTags.HTTP_URL]:
|
|
15
|
+
[Tags_1.OpentracingTags.HTTP_URL]: buildFullPath_1.default(config.baseURL, http.getUri(config)),
|
|
16
16
|
});
|
|
17
|
-
span === null || span === void 0 ? void 0 : span.log({ 'request-headers':
|
|
17
|
+
span === null || span === void 0 ? void 0 : span.log({ 'request-headers': utils_1.cloneAndSanitizeHeaders(config.headers) });
|
|
18
18
|
};
|
|
19
|
-
exports.injectRequestInfoOnSpan = injectRequestInfoOnSpan;
|
|
20
19
|
// Response may be undefined in case of client timeout, invalid URL, ...
|
|
21
|
-
|
|
20
|
+
exports.injectResponseInfoOnSpan = (span, response) => {
|
|
22
21
|
if (!response) {
|
|
23
|
-
span === null || span === void 0 ? void 0 : span.setTag("http.no_response" /*
|
|
22
|
+
span === null || span === void 0 ? void 0 : span.setTag("http.no_response" /* HTTP_NO_RESPONSE */, 'true');
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
26
|
-
span === null || span === void 0 ? void 0 : span.log({ 'response-headers':
|
|
25
|
+
span === null || span === void 0 ? void 0 : span.log({ 'response-headers': utils_1.cloneAndSanitizeHeaders(response.headers) });
|
|
27
26
|
span === null || span === void 0 ? void 0 : span.setTag(Tags_1.OpentracingTags.HTTP_STATUS_CODE, response.status);
|
|
28
27
|
if (response.headers[constants_1.ROUTER_CACHE_HEADER]) {
|
|
29
|
-
span === null || span === void 0 ? void 0 : span.setTag("http.cache.router" /*
|
|
28
|
+
span === null || span === void 0 ? void 0 : span.setTag("http.cache.router" /* HTTP_ROUTER_CACHE_RESULT */, response.headers[constants_1.ROUTER_CACHE_HEADER]);
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
|
-
exports.injectResponseInfoOnSpan = injectResponseInfoOnSpan;
|
|
@@ -5,7 +5,7 @@ const axios_1 = require("axios");
|
|
|
5
5
|
const tracing_1 = require("../../tracing");
|
|
6
6
|
const Tags_1 = require("../../tracing/Tags");
|
|
7
7
|
const cache_1 = require("./cache");
|
|
8
|
-
|
|
8
|
+
exports.createHttpClientTracingMiddleware = ({ tracer, logger, clientName, hasMemoryCacheMiddleware, hasDiskCacheMiddleware, }) => {
|
|
9
9
|
return async function tracingMiddleware(ctx, next) {
|
|
10
10
|
var _a;
|
|
11
11
|
if (!tracer.isTraceSampled) {
|
|
@@ -18,20 +18,20 @@ const createHttpClientTracingMiddleware = ({ tracer, logger, clientName, hasMemo
|
|
|
18
18
|
const span = tracer.startSpan(spanName, { childOf: rootSpan });
|
|
19
19
|
ctx.tracing = {
|
|
20
20
|
...ctx.config.tracing,
|
|
21
|
-
isSampled:
|
|
21
|
+
isSampled: tracing_1.getTraceInfo(span).isSampled,
|
|
22
22
|
logger,
|
|
23
23
|
rootSpan: span,
|
|
24
24
|
tracer,
|
|
25
25
|
};
|
|
26
26
|
ctx.config.tracing = ctx.tracing;
|
|
27
|
-
const hasMemoCache = !(!
|
|
28
|
-
const hasMemoryCache = hasMemoryCacheMiddleware && !!
|
|
29
|
-
const hasDiskCache = hasDiskCacheMiddleware && !!
|
|
27
|
+
const hasMemoCache = !(!cache_1.isLocallyCacheable(ctx.config, cache_1.CacheType.Any) || !ctx.config.memoizable);
|
|
28
|
+
const hasMemoryCache = hasMemoryCacheMiddleware && !!cache_1.isLocallyCacheable(ctx.config, cache_1.CacheType.Memory);
|
|
29
|
+
const hasDiskCache = hasDiskCacheMiddleware && !!cache_1.isLocallyCacheable(ctx.config, cache_1.CacheType.Disk);
|
|
30
30
|
span === null || span === void 0 ? void 0 : span.addTags({
|
|
31
|
-
["http.cache.memoization.enabled" /*
|
|
32
|
-
["http.cache.memory.enabled" /*
|
|
33
|
-
["http.cache.disk.enabled" /*
|
|
34
|
-
["http.client.name" /*
|
|
31
|
+
["http.cache.memoization.enabled" /* HTTP_MEMOIZATION_CACHE_ENABLED */]: hasMemoCache,
|
|
32
|
+
["http.cache.memory.enabled" /* HTTP_MEMORY_CACHE_ENABLED */]: hasMemoryCache,
|
|
33
|
+
["http.cache.disk.enabled" /* HTTP_DISK_CACHE_ENABLED */]: hasDiskCache,
|
|
34
|
+
["http.client.name" /* HTTP_CLIENT_NAME */]: clientName,
|
|
35
35
|
});
|
|
36
36
|
let response;
|
|
37
37
|
try {
|
|
@@ -53,10 +53,9 @@ const createHttpClientTracingMiddleware = ({ tracer, logger, clientName, hasMemo
|
|
|
53
53
|
span === null || span === void 0 ? void 0 : span.setTag(Tags_1.OpentracingTags.HTTP_STATUS_CODE, response.status);
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
|
-
span === null || span === void 0 ? void 0 : span.setTag("http.no_response" /*
|
|
56
|
+
span === null || span === void 0 ? void 0 : span.setTag("http.no_response" /* HTTP_NO_RESPONSE */, true);
|
|
57
57
|
}
|
|
58
58
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
exports.createHttpClientTracingMiddleware = createHttpClientTracingMiddleware;
|
|
@@ -8,7 +8,7 @@ import { IOContext } from '../service/worker/runtime/typings';
|
|
|
8
8
|
import { SpanReferenceTypes } from '../tracing';
|
|
9
9
|
import { IUserLandTracer } from '../tracing/UserLandTracer';
|
|
10
10
|
import { Cached, CacheType } from './middlewares/cache';
|
|
11
|
-
export type InflightKeyGenerator = (x: RequestConfig) => string;
|
|
11
|
+
export declare type InflightKeyGenerator = (x: RequestConfig) => string;
|
|
12
12
|
interface RequestTracingUserConfig {
|
|
13
13
|
rootSpan?: Span;
|
|
14
14
|
referenceType?: SpanReferenceTypes;
|
|
@@ -68,7 +68,7 @@ export interface MiddlewareContext {
|
|
|
68
68
|
inflightHit?: boolean;
|
|
69
69
|
memoizedHit?: boolean;
|
|
70
70
|
}
|
|
71
|
-
export type CacheStorage = CacheLayer<string, Cached>;
|
|
71
|
+
export declare type CacheStorage = CacheLayer<string, Cached>;
|
|
72
72
|
export interface InstanceOptions {
|
|
73
73
|
authType?: AuthType;
|
|
74
74
|
timeout?: number;
|
package/lib/caches/DiskCache.js
CHANGED
|
@@ -16,7 +16,7 @@ class DiskCache {
|
|
|
16
16
|
this.total = 0;
|
|
17
17
|
this.has = (key) => {
|
|
18
18
|
const pathKey = this.getPathKey(key);
|
|
19
|
-
return
|
|
19
|
+
return fs_extra_1.pathExistsSync(pathKey);
|
|
20
20
|
};
|
|
21
21
|
this.getStats = (name = 'disk-cache') => {
|
|
22
22
|
const stats = {
|
|
@@ -64,7 +64,7 @@ class DiskCache {
|
|
|
64
64
|
});
|
|
65
65
|
return !failure;
|
|
66
66
|
};
|
|
67
|
-
this.getPathKey = (key) =>
|
|
67
|
+
this.getPathKey = (key) => path_1.join(this.cachePath, key);
|
|
68
68
|
this.lock = new rwlock_1.default();
|
|
69
69
|
}
|
|
70
70
|
}
|
package/lib/caches/LRUCache.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export declare class LRUCache<K, V> implements CacheLayer<K, V> {
|
|
|
9
9
|
private disposed;
|
|
10
10
|
constructor(options: LRU.Options<K, V>);
|
|
11
11
|
get: (key: K) => V | void;
|
|
12
|
-
getOrSet: (key: K, fetcher?: () => Promise<FetchResult<V>>) => Promise<V | void>;
|
|
13
|
-
set: (key: K, value: V, maxAge?: number) => boolean;
|
|
12
|
+
getOrSet: (key: K, fetcher?: (() => Promise<FetchResult<V>>) | undefined) => Promise<V | void>;
|
|
13
|
+
set: (key: K, value: V, maxAge?: number | undefined) => boolean;
|
|
14
14
|
has: (key: K) => boolean;
|
|
15
15
|
getStats: (name?: string) => LRUStats;
|
|
16
16
|
}
|
|
@@ -15,7 +15,7 @@ export declare class LRUDiskCache<V> implements CacheLayer<string, V> {
|
|
|
15
15
|
has: (key: string) => boolean;
|
|
16
16
|
getStats: (name?: string) => LRUStats;
|
|
17
17
|
get: (key: string) => Promise<V | void>;
|
|
18
|
-
set: (key: string, value: V, maxAge?: number) => Promise<boolean>;
|
|
18
|
+
set: (key: string, value: V, maxAge?: number | undefined) => Promise<boolean>;
|
|
19
19
|
private getPathKey;
|
|
20
20
|
private deleteFile;
|
|
21
21
|
}
|
|
@@ -93,7 +93,7 @@ class LRUDiskCache {
|
|
|
93
93
|
return !failure;
|
|
94
94
|
};
|
|
95
95
|
this.getPathKey = (key) => {
|
|
96
|
-
return
|
|
96
|
+
return path_1.join(this.cachePath, key);
|
|
97
97
|
};
|
|
98
98
|
this.deleteFile = async (key) => {
|
|
99
99
|
const pathKey = this.getPathKey(key);
|
|
@@ -101,7 +101,7 @@ class LRUDiskCache {
|
|
|
101
101
|
const failure = new Promise(resolve => {
|
|
102
102
|
this.lock.writeLock(key, async (release) => {
|
|
103
103
|
try {
|
|
104
|
-
const removePromise = await
|
|
104
|
+
const removePromise = await fs_extra_1.remove(pathKey);
|
|
105
105
|
release();
|
|
106
106
|
resolve(removePromise);
|
|
107
107
|
}
|
|
@@ -5,8 +5,8 @@ export declare class MultilayeredCache<K, V> implements CacheLayer<K, V> {
|
|
|
5
5
|
private hits;
|
|
6
6
|
private total;
|
|
7
7
|
constructor(caches: Array<CacheLayer<K, V>>);
|
|
8
|
-
get: (key: K, fetcher?: () => Promise<FetchResult<V>>) => Promise<V | void>;
|
|
9
|
-
set: (key: K, value: V, maxAge?: number) => Promise<boolean>;
|
|
8
|
+
get: (key: K, fetcher?: (() => Promise<FetchResult<V>>) | undefined) => Promise<V | void>;
|
|
9
|
+
set: (key: K, value: V, maxAge?: number | undefined) => Promise<boolean>;
|
|
10
10
|
has: (key: K) => Promise<boolean>;
|
|
11
11
|
getStats: (name?: string) => MultilayerStats;
|
|
12
12
|
private findIndex;
|
|
@@ -26,18 +26,18 @@ class MultilayeredCache {
|
|
|
26
26
|
}
|
|
27
27
|
successIndex = Infinity;
|
|
28
28
|
}
|
|
29
|
-
const failedCaches =
|
|
30
|
-
const [firstPromise] =
|
|
29
|
+
const failedCaches = ramda_1.slice(0, successIndex, this.caches);
|
|
30
|
+
const [firstPromise] = ramda_1.map(cache => cache.set(key, value, maxAge), failedCaches);
|
|
31
31
|
await firstPromise;
|
|
32
32
|
return value;
|
|
33
33
|
};
|
|
34
34
|
this.set = async (key, value, maxAge) => {
|
|
35
|
-
const isSet = await Promise.all(
|
|
36
|
-
return
|
|
35
|
+
const isSet = await Promise.all(ramda_1.map(cache => cache.set(key, value, maxAge), this.caches));
|
|
36
|
+
return ramda_1.any(item => item, isSet);
|
|
37
37
|
};
|
|
38
38
|
this.has = async (key) => {
|
|
39
|
-
const hasList = await Promise.all(
|
|
40
|
-
return
|
|
39
|
+
const hasList = await Promise.all(ramda_1.map(cache => cache.has(key), this.caches));
|
|
40
|
+
return ramda_1.any(item => item, hasList);
|
|
41
41
|
};
|
|
42
42
|
this.getStats = (name = 'multilayred-cache') => {
|
|
43
43
|
const multilayerStats = {
|
package/lib/caches/index.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
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
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
12
8
|
}));
|
|
13
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
15
11
|
};
|
|
16
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
13
|
__exportStar(require("./CacheLayer"), exports);
|
package/lib/caches/typings.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export type FetchResult<V> = {
|
|
1
|
+
export declare type FetchResult<V> = {
|
|
2
2
|
value: V;
|
|
3
3
|
maxAge?: number;
|
|
4
4
|
};
|
|
5
|
-
export type DiskStats = {
|
|
5
|
+
export declare type DiskStats = {
|
|
6
6
|
hits: number;
|
|
7
7
|
total: number;
|
|
8
8
|
name: string;
|
|
9
9
|
};
|
|
10
|
-
export type LRUStats = {
|
|
10
|
+
export declare type LRUStats = {
|
|
11
11
|
itemCount: number;
|
|
12
12
|
length: number;
|
|
13
13
|
disposedItems: number;
|
|
@@ -17,13 +17,13 @@ export type LRUStats = {
|
|
|
17
17
|
name: string;
|
|
18
18
|
total: number;
|
|
19
19
|
};
|
|
20
|
-
export type MultilayerStats = {
|
|
20
|
+
export declare type MultilayerStats = {
|
|
21
21
|
hitRate: number | undefined;
|
|
22
22
|
hits: number;
|
|
23
23
|
total: number;
|
|
24
24
|
name: string;
|
|
25
25
|
};
|
|
26
|
-
export type LRUDiskCacheOptions = {
|
|
26
|
+
export declare type LRUDiskCacheOptions = {
|
|
27
27
|
/**
|
|
28
28
|
* The maximum size of the cache, checked by applying the length
|
|
29
29
|
* function to all values in the cache. Not setting this is kind of silly,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IOContext } from '../service/worker/runtime/typings';
|
|
2
2
|
import { HttpClient } from '../HttpClient/HttpClient';
|
|
3
3
|
import { InstanceOptions } from '../HttpClient/typings';
|
|
4
|
-
export type IOClientConstructor = new (context: IOContext, options?: InstanceOptions) => IOClient;
|
|
4
|
+
export declare type IOClientConstructor = new (context: IOContext, options?: InstanceOptions) => IOClient;
|
|
5
5
|
/**
|
|
6
6
|
* A client that can be instantiated by the Serviceruntime layer.
|
|
7
7
|
*/
|
|
@@ -6,7 +6,7 @@ import { ID, MasterData, PaymentProvider } from './external';
|
|
|
6
6
|
import { Apps, Assets, BillingMetrics, Events, Registry, Router, VBase, Workspaces } from './infra';
|
|
7
7
|
import { IOClientConstructor } from './IOClient';
|
|
8
8
|
import { LicenseManager, Segment, Session, TenantClient } from './janus';
|
|
9
|
-
export type ClientsImplementation<T extends IOClients> = new (clientOptions: Record<string, InstanceOptions>, ctx: IOContext) => T;
|
|
9
|
+
export declare type ClientsImplementation<T extends IOClients> = new (clientOptions: Record<string, InstanceOptions>, ctx: IOContext) => T;
|
|
10
10
|
export declare class IOClients {
|
|
11
11
|
private clientOptions;
|
|
12
12
|
private ctx;
|
|
@@ -17,7 +17,7 @@ class AppClient extends IOClient_1.IOClient {
|
|
|
17
17
|
let baseURL;
|
|
18
18
|
if (appVersion) {
|
|
19
19
|
const [major] = appVersion.split('.');
|
|
20
|
-
baseURL =
|
|
20
|
+
baseURL = routes_1.formatPrivateRoute({ account, workspace, vendor, name, major, protocol });
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
23
|
console.warn(`${account} in ${workspace} is using old routing for ${app}. Please change vendor.app to vendor.app@major in client ${(options && options.name) || ''}`);
|
|
@@ -17,7 +17,7 @@ class AppGraphQLClient extends IOGraphQLClient_1.IOGraphQLClient {
|
|
|
17
17
|
let baseURL;
|
|
18
18
|
if (appVersion) {
|
|
19
19
|
const [major] = appVersion.split('.');
|
|
20
|
-
baseURL =
|
|
20
|
+
baseURL = routes_1.formatPrivateRoute({ account, workspace, major, name, vendor, protocol, path: '/_v/graphql' });
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
23
|
console.warn(`${account} in ${workspace} is using old routing for ${app}. Please change vendor.app to vendor.app@major in client ${(options && options.name) || ''}`);
|
|
@@ -3,7 +3,7 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
3
3
|
import { AppClient } from './AppClient';
|
|
4
4
|
export declare class Billing extends AppClient {
|
|
5
5
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
6
|
-
status: (tracingConfig?: RequestTracingConfig) => Promise<ContractStatus>;
|
|
6
|
+
status: (tracingConfig?: RequestTracingConfig | undefined) => Promise<ContractStatus>;
|
|
7
7
|
}
|
|
8
8
|
export declare enum ContractStatus {
|
|
9
9
|
ACTIVE = "active_contract",
|
|
@@ -8,17 +8,17 @@ import { AppClient } from './AppClient';
|
|
|
8
8
|
export declare class Builder extends AppClient {
|
|
9
9
|
private stickyHost;
|
|
10
10
|
constructor(ioContext: IOContext, opts?: InstanceOptions);
|
|
11
|
-
availability: (app: string, hintIndex: number, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
11
|
+
availability: (app: string, hintIndex: number, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
|
|
12
12
|
host: string;
|
|
13
13
|
hostname: string | undefined;
|
|
14
14
|
score: number;
|
|
15
15
|
}>;
|
|
16
|
-
clean: (app: string, tracingConfig?: RequestTracingConfig) => Promise<BuildResult>;
|
|
17
|
-
getPinnedDependencies: (tracingConfig?: RequestTracingConfig) => Promise<any>;
|
|
18
|
-
linkApp: (app: string, files: File[], zipOptions?: ZipOptions, params?: RequestParams, tracingConfig?: RequestTracingConfig) => Promise<BuildResult>;
|
|
19
|
-
publishApp: (app: string, files: File[], zipOptions?: ZipOptions, params?: RequestParams, tracingConfig?: RequestTracingConfig) => Promise<BuildResult>;
|
|
20
|
-
relinkApp: (app: string, changes: Change[], params?: RequestParams, tracingConfig?: RequestTracingConfig) => Promise<BuildResult>;
|
|
21
|
-
testApp: (app: string, files: File[], zipOptions?: ZipOptions, params?: RequestParams, tracingConfig?: RequestTracingConfig) => Promise<BuildResult>;
|
|
16
|
+
clean: (app: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<BuildResult>;
|
|
17
|
+
getPinnedDependencies: (tracingConfig?: RequestTracingConfig | undefined) => Promise<any>;
|
|
18
|
+
linkApp: (app: string, files: File[], zipOptions?: ZipOptions, params?: RequestParams, tracingConfig?: RequestTracingConfig | undefined) => Promise<BuildResult>;
|
|
19
|
+
publishApp: (app: string, files: File[], zipOptions?: ZipOptions, params?: RequestParams, tracingConfig?: RequestTracingConfig | undefined) => Promise<BuildResult>;
|
|
20
|
+
relinkApp: (app: string, changes: Change[], params?: RequestParams, tracingConfig?: RequestTracingConfig | undefined) => Promise<BuildResult>;
|
|
21
|
+
testApp: (app: string, files: File[], zipOptions?: ZipOptions, params?: RequestParams, tracingConfig?: RequestTracingConfig | undefined) => Promise<BuildResult>;
|
|
22
22
|
private zipAndSend;
|
|
23
23
|
}
|
|
24
24
|
interface RequestParams {
|
|
@@ -83,7 +83,7 @@ class Builder extends AppClient_1.AppClient {
|
|
|
83
83
|
if (indexOfManifest === -1) {
|
|
84
84
|
throw new Error('No manifest.json file found in files.');
|
|
85
85
|
}
|
|
86
|
-
const zip =
|
|
86
|
+
const zip = archiver_1.default('zip', { zlib });
|
|
87
87
|
// Throw stream errors so they reject the promise chain.
|
|
88
88
|
zip.on('error', (e) => {
|
|
89
89
|
throw e;
|
|
@@ -5,7 +5,7 @@ export interface IndexedByFrom {
|
|
|
5
5
|
messages: Array<Omit<Message, 'from'>>;
|
|
6
6
|
from: string;
|
|
7
7
|
}
|
|
8
|
-
export type Behavior = 'FULL' | 'USER_ONLY' | 'USER_AND_APP';
|
|
8
|
+
export declare type Behavior = 'FULL' | 'USER_ONLY' | 'USER_AND_APP';
|
|
9
9
|
export interface Message {
|
|
10
10
|
content: string;
|
|
11
11
|
context?: string;
|
|
@@ -13,7 +13,7 @@ class MessagesGraphQL extends AppGraphQLClient_1.AppGraphQLClient {
|
|
|
13
13
|
const allMessages = indexedByFrom.reduce((acc, { from, messages }) => {
|
|
14
14
|
return acc.concat(messages.map(message => ({ from, message })));
|
|
15
15
|
}, []);
|
|
16
|
-
const batchedMessages =
|
|
16
|
+
const batchedMessages = ramda_1.splitEvery(MAX_BATCH_SIZE, allMessages);
|
|
17
17
|
const metric = 'messages-translate-v2';
|
|
18
18
|
return Promise.all(batchedMessages.map(batch => {
|
|
19
19
|
const indexedBatch = batch.reduce((acc, { from, message }) => {
|
|
@@ -28,7 +28,7 @@ class MessagesGraphQL extends AppGraphQLClient_1.AppGraphQLClient {
|
|
|
28
28
|
}, {});
|
|
29
29
|
const batchArgs = {
|
|
30
30
|
...rest,
|
|
31
|
-
indexedByFrom:
|
|
31
|
+
indexedByFrom: ramda_1.values(indexedBatch),
|
|
32
32
|
};
|
|
33
33
|
return this.graphql.query({
|
|
34
34
|
query: `
|
|
@@ -43,7 +43,7 @@ class MessagesGraphQL extends AppGraphQLClient_1.AppGraphQLClient {
|
|
|
43
43
|
requestSpanNameSuffix: metric,
|
|
44
44
|
...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
|
|
45
45
|
},
|
|
46
|
-
}).then(
|
|
46
|
+
}).then(ramda_1.path(['data', 'translate']));
|
|
47
47
|
})).then(ramda_1.flatten);
|
|
48
48
|
}
|
|
49
49
|
async translate(args, tracingConfig) {
|
|
@@ -7,16 +7,16 @@ const settings_1 = require("../../service/worker/runtime/http/middlewares/settin
|
|
|
7
7
|
const app_1 = require("../../utils/app");
|
|
8
8
|
const AppClient_1 = require("./AppClient");
|
|
9
9
|
const LINKED_ROUTE = 'linked';
|
|
10
|
-
const containsLinks =
|
|
10
|
+
const containsLinks = ramda_1.any(app_1.isLinkedApp);
|
|
11
11
|
class Settings extends AppClient_1.AppClient {
|
|
12
12
|
constructor(context, options) {
|
|
13
13
|
super('vtex.settings-server@0.x', context, options);
|
|
14
14
|
}
|
|
15
15
|
getFilteredDependencies(appAtMajor, dependencies) {
|
|
16
|
-
return
|
|
16
|
+
return settings_1.getFilteredDependencies(appAtMajor, dependencies);
|
|
17
17
|
}
|
|
18
18
|
getDependenciesHash(dependencies) {
|
|
19
|
-
return
|
|
19
|
+
return settings_1.getDependenciesHash(dependencies);
|
|
20
20
|
}
|
|
21
21
|
async getSettings(dependencies, appAtMajor, params, tracingConfig) {
|
|
22
22
|
const filtered = this.getFilteredDependencies(appAtMajor, dependencies);
|
|
@@ -7,16 +7,16 @@ import { Product } from './product';
|
|
|
7
7
|
import { SKU } from './sku';
|
|
8
8
|
export declare class CatalogGraphQL extends AppGraphQLClient {
|
|
9
9
|
constructor(ctx: IOContext, opts?: InstanceOptions);
|
|
10
|
-
sku: (id: string, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
10
|
+
sku: (id: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
|
|
11
11
|
sku: SKU;
|
|
12
12
|
} | undefined>;
|
|
13
|
-
product: (id: string, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
13
|
+
product: (id: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
|
|
14
14
|
product: Product;
|
|
15
15
|
} | undefined>;
|
|
16
|
-
category: (id: string, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
16
|
+
category: (id: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
|
|
17
17
|
category: Category;
|
|
18
18
|
} | undefined>;
|
|
19
|
-
brand: (id: string, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
19
|
+
brand: (id: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
|
|
20
20
|
brand: Brand;
|
|
21
21
|
} | undefined>;
|
|
22
22
|
}
|