@vtex/api 6.48.1-beta.3 → 6.49.1
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
|
@@ -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("axios/lib/core/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 = setupAxios_1.getConfiguredAxios();
|
|
13
|
+
const http = (0, setupAxios_1.getConfiguredAxios)();
|
|
14
14
|
const paramsSerializer = (params) => {
|
|
15
|
-
return qs_1.stringify(params, { arrayFormat: 'repeat' });
|
|
15
|
+
return (0, qs_1.stringify)(params, { arrayFormat: 'repeat' });
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
const defaultsMiddleware = ({ baseURL, rawHeaders, params, timeout, retries, verbose, exponentialTimeoutCoefficient, initialBackoffDelay, exponentialBackoffCoefficient, httpsAgent }) => {
|
|
18
18
|
const countByMetric = {};
|
|
19
|
-
const headers = renameBy_1.renameBy(ramda_1.toLower, rawHeaders);
|
|
19
|
+
const headers = (0, 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 @@ exports.defaultsMiddleware = ({ baseURL, rawHeaders, params, timeout, retries, v
|
|
|
33
33
|
...ctx.config,
|
|
34
34
|
headers: {
|
|
35
35
|
...headers,
|
|
36
|
-
...renameBy_1.renameBy(ramda_1.toLower, ctx.config.headers),
|
|
36
|
+
...(0, renameBy_1.renameBy)(ramda_1.toLower, ctx.config.headers),
|
|
37
37
|
},
|
|
38
38
|
params: {
|
|
39
39
|
...params,
|
|
@@ -50,7 +50,7 @@ exports.defaultsMiddleware = ({ baseURL, rawHeaders, params, timeout, retries, v
|
|
|
50
50
|
}
|
|
51
51
|
if ((_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.isSampled) {
|
|
52
52
|
const { config } = ctx;
|
|
53
|
-
const fullUrl = buildFullPath_1.default(config.baseURL, http.getUri(config));
|
|
53
|
+
const fullUrl = (0, 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,16 +59,17 @@ exports.defaultsMiddleware = ({ baseURL, rawHeaders, params, timeout, retries, v
|
|
|
59
59
|
return next();
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
+
exports.defaultsMiddleware = defaultsMiddleware;
|
|
62
63
|
const ROUTER_CACHE_KEY = 'x-router-cache';
|
|
63
64
|
const ROUTER_CACHE_HIT = 'HIT';
|
|
64
65
|
const ROUTER_CACHE_REVALIDATED = 'REVALIDATED';
|
|
65
|
-
|
|
66
|
+
const routerCacheMiddleware = async (ctx, next) => {
|
|
66
67
|
var _a, _b, _c, _d, _e;
|
|
67
68
|
await next();
|
|
68
69
|
const routerCacheHit = (_b = (_a = ctx.response) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b[ROUTER_CACHE_KEY];
|
|
69
70
|
const status = (_c = ctx.response) === null || _c === void 0 ? void 0 : _c.status;
|
|
70
71
|
if (routerCacheHit) {
|
|
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);
|
|
72
|
+
(_e = (_d = ctx.tracing) === null || _d === void 0 ? void 0 : _d.rootSpan) === null || _e === void 0 ? void 0 : _e.setTag("http.cache.router" /* CustomHttpTags.HTTP_ROUTER_CACHE_RESULT */, routerCacheHit);
|
|
72
73
|
}
|
|
73
74
|
if (routerCacheHit === ROUTER_CACHE_HIT || (routerCacheHit === ROUTER_CACHE_REVALIDATED && status !== 304)) {
|
|
74
75
|
ctx.cacheHit = {
|
|
@@ -79,7 +80,9 @@ exports.routerCacheMiddleware = async (ctx, next) => {
|
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
};
|
|
82
|
-
exports.
|
|
83
|
+
exports.routerCacheMiddleware = routerCacheMiddleware;
|
|
84
|
+
const requestMiddleware = (limit) => async (ctx, next) => {
|
|
83
85
|
const makeRequest = () => http.request(ctx.config);
|
|
84
86
|
ctx.response = await (limit ? limit(makeRequest) : makeRequest());
|
|
85
87
|
};
|
|
88
|
+
exports.requestMiddleware = requestMiddleware;
|
|
@@ -7,15 +7,16 @@ 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
|
+
const getConfiguredAxios = () => {
|
|
11
11
|
const httpAgent = HttpAgentSingleton_1.HttpAgentSingleton.getHttpAgent();
|
|
12
12
|
const http = axios_1.default.create({
|
|
13
13
|
httpAgent,
|
|
14
14
|
});
|
|
15
|
-
interceptors_1.addTracingPreRequestInterceptor(http);
|
|
15
|
+
(0, 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
|
-
interceptors_1.addTracingResponseInterceptor(http);
|
|
19
|
-
interceptors_1.addExponentialBackoffResponseInterceptor(http);
|
|
18
|
+
(0, interceptors_1.addTracingResponseInterceptor)(http);
|
|
19
|
+
(0, 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 = retry_1.isAbortedOrNetworkErrorOrRouterTimeout(error) && retryCount < config.retries;
|
|
32
|
+
const shouldRetry = (0, 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,15 +40,16 @@ 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" /* SETUP_REQUEST_RETRY */, ["retry-number" /* RETRY_NUMBER */]: config.retryCount, ["retry-in" /* RETRY_IN */]: delay });
|
|
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" /* HttpLogEvents.SETUP_REQUEST_RETRY */, ["retry-number" /* HttpRetryLogFields.RETRY_NUMBER */]: config.retryCount, ["retry-in" /* HttpRetryLogFields.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" /* HTTP_RETRY_COUNT */]: config.retryCount,
|
|
46
|
-
["http.retry.error.code" /* HTTP_RETRY_ERROR_CODE */]: error.code,
|
|
45
|
+
["http.retry.count" /* CustomHttpTags.HTTP_RETRY_COUNT */]: config.retryCount,
|
|
46
|
+
["http.retry.error.code" /* CustomHttpTags.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
|
+
const addExponentialBackoffResponseInterceptor = (http) => {
|
|
53
53
|
http.interceptors.response.use(undefined, onResponseError(http));
|
|
54
54
|
};
|
|
55
|
+
exports.addExponentialBackoffResponseInterceptor = addExponentialBackoffResponseInterceptor;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addTracingResponseInterceptor = exports.addTracingPreRequestInterceptor = exports.addExponentialBackoffResponseInterceptor = void 0;
|
|
3
4
|
var exponentialBackoff_1 = require("./exponentialBackoff");
|
|
4
5
|
Object.defineProperty(exports, "addExponentialBackoffResponseInterceptor", { enumerable: true, get: function () { return exponentialBackoff_1.addExponentialBackoffResponseInterceptor; } });
|
|
5
6
|
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: [tracing_1.createSpanReference(rootSpan, SpanReferenceTypes_1.SpanReferenceTypes.CHILD_OF)],
|
|
18
|
+
references: [(0, tracing_1.createSpanReference)(rootSpan, SpanReferenceTypes_1.SpanReferenceTypes.CHILD_OF)],
|
|
19
19
|
})
|
|
20
20
|
: tracer.startSpan(spanName);
|
|
21
|
-
spanSetup_1.injectRequestInfoOnSpan(span, http, config);
|
|
21
|
+
(0, 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
|
-
spanSetup_1.injectResponseInfoOnSpan(requestSpan, response);
|
|
32
|
+
(0, 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
|
-
spanSetup_1.injectResponseInfoOnSpan(requestSpan, err.response);
|
|
42
|
+
(0, 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
|
-
|
|
48
|
-
// Usando type assertion para compatibilidade com TypeScript 3.9.7
|
|
47
|
+
const addTracingPreRequestInterceptor = (http) => {
|
|
49
48
|
const requestTracingInterceptor = http.interceptors.request.use(preRequestInterceptor(http), undefined);
|
|
50
49
|
return { requestTracingInterceptor };
|
|
51
50
|
};
|
|
52
|
-
exports.
|
|
53
|
-
|
|
51
|
+
exports.addTracingPreRequestInterceptor = addTracingPreRequestInterceptor;
|
|
52
|
+
const addTracingResponseInterceptor = (http) => {
|
|
54
53
|
const responseTracingInterceptor = http.interceptors.response.use(onResponseSuccess, onResponseError);
|
|
55
54
|
return { responseTracingInterceptor };
|
|
56
55
|
};
|
|
56
|
+
exports.addTracingResponseInterceptor = addTracingResponseInterceptor;
|
|
@@ -4,27 +4,29 @@ 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("axios/lib/core/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
|
+
const 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]: buildFullPath_1.default(config.baseURL, http.getUri(config)),
|
|
15
|
+
[Tags_1.OpentracingTags.HTTP_URL]: (0, buildFullPath_1.default)(config.baseURL, http.getUri(config)),
|
|
16
16
|
});
|
|
17
|
-
span === null || span === void 0 ? void 0 : span.log({ 'request-headers': utils_1.cloneAndSanitizeHeaders(config.headers) });
|
|
17
|
+
span === null || span === void 0 ? void 0 : span.log({ 'request-headers': (0, utils_1.cloneAndSanitizeHeaders)(config.headers) });
|
|
18
18
|
};
|
|
19
|
+
exports.injectRequestInfoOnSpan = injectRequestInfoOnSpan;
|
|
19
20
|
// Response may be undefined in case of client timeout, invalid URL, ...
|
|
20
|
-
|
|
21
|
+
const injectResponseInfoOnSpan = (span, response) => {
|
|
21
22
|
if (!response) {
|
|
22
|
-
span === null || span === void 0 ? void 0 : span.setTag("http.no_response" /* HTTP_NO_RESPONSE */, 'true');
|
|
23
|
+
span === null || span === void 0 ? void 0 : span.setTag("http.no_response" /* CustomHttpTags.HTTP_NO_RESPONSE */, 'true');
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
span === null || span === void 0 ? void 0 : span.log({ 'response-headers': utils_1.cloneAndSanitizeHeaders(response.headers) });
|
|
26
|
+
span === null || span === void 0 ? void 0 : span.log({ 'response-headers': (0, utils_1.cloneAndSanitizeHeaders)(response.headers) });
|
|
26
27
|
span === null || span === void 0 ? void 0 : span.setTag(Tags_1.OpentracingTags.HTTP_STATUS_CODE, response.status);
|
|
27
28
|
if (response.headers[constants_1.ROUTER_CACHE_HEADER]) {
|
|
28
|
-
span === null || span === void 0 ? void 0 : span.setTag("http.cache.router" /* HTTP_ROUTER_CACHE_RESULT */, response.headers[constants_1.ROUTER_CACHE_HEADER]);
|
|
29
|
+
span === null || span === void 0 ? void 0 : span.setTag("http.cache.router" /* CustomHttpTags.HTTP_ROUTER_CACHE_RESULT */, response.headers[constants_1.ROUTER_CACHE_HEADER]);
|
|
29
30
|
}
|
|
30
31
|
};
|
|
32
|
+
exports.injectResponseInfoOnSpan = injectResponseInfoOnSpan;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createHttpClientTracingMiddleware = void 0;
|
|
4
|
-
const axios_1 = require("axios");
|
|
5
4
|
const tracing_1 = require("../../tracing");
|
|
6
5
|
const Tags_1 = require("../../tracing/Tags");
|
|
7
6
|
const cache_1 = require("./cache");
|
|
8
|
-
|
|
7
|
+
const createHttpClientTracingMiddleware = ({ tracer, logger, clientName, hasMemoryCacheMiddleware, hasDiskCacheMiddleware, }) => {
|
|
9
8
|
return async function tracingMiddleware(ctx, next) {
|
|
10
9
|
var _a;
|
|
11
10
|
if (!tracer.isTraceSampled) {
|
|
@@ -18,20 +17,20 @@ exports.createHttpClientTracingMiddleware = ({ tracer, logger, clientName, hasMe
|
|
|
18
17
|
const span = tracer.startSpan(spanName, { childOf: rootSpan });
|
|
19
18
|
ctx.tracing = {
|
|
20
19
|
...ctx.config.tracing,
|
|
21
|
-
isSampled: tracing_1.getTraceInfo(span).isSampled,
|
|
20
|
+
isSampled: (0, tracing_1.getTraceInfo)(span).isSampled,
|
|
22
21
|
logger,
|
|
23
22
|
rootSpan: span,
|
|
24
23
|
tracer,
|
|
25
24
|
};
|
|
26
25
|
ctx.config.tracing = ctx.tracing;
|
|
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);
|
|
26
|
+
const hasMemoCache = !(!(0, cache_1.isLocallyCacheable)(ctx.config, cache_1.CacheType.Any) || !ctx.config.memoizable);
|
|
27
|
+
const hasMemoryCache = hasMemoryCacheMiddleware && !!(0, cache_1.isLocallyCacheable)(ctx.config, cache_1.CacheType.Memory);
|
|
28
|
+
const hasDiskCache = hasDiskCacheMiddleware && !!(0, cache_1.isLocallyCacheable)(ctx.config, cache_1.CacheType.Disk);
|
|
30
29
|
span === null || span === void 0 ? void 0 : span.addTags({
|
|
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,
|
|
30
|
+
["http.cache.memoization.enabled" /* CustomHttpTags.HTTP_MEMOIZATION_CACHE_ENABLED */]: hasMemoCache,
|
|
31
|
+
["http.cache.memory.enabled" /* CustomHttpTags.HTTP_MEMORY_CACHE_ENABLED */]: hasMemoryCache,
|
|
32
|
+
["http.cache.disk.enabled" /* CustomHttpTags.HTTP_DISK_CACHE_ENABLED */]: hasDiskCache,
|
|
33
|
+
["http.client.name" /* CustomHttpTags.HTTP_CLIENT_NAME */]: clientName,
|
|
35
34
|
});
|
|
36
35
|
let response;
|
|
37
36
|
try {
|
|
@@ -39,9 +38,6 @@ exports.createHttpClientTracingMiddleware = ({ tracer, logger, clientName, hasMe
|
|
|
39
38
|
response = ctx.response;
|
|
40
39
|
}
|
|
41
40
|
catch (err) {
|
|
42
|
-
if (!(err instanceof axios_1.AxiosError)) {
|
|
43
|
-
throw err;
|
|
44
|
-
}
|
|
45
41
|
response = err.response;
|
|
46
42
|
if ((_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.isSampled) {
|
|
47
43
|
tracing_1.ErrorReport.create({ originalError: err }).injectOnSpan(span, logger);
|
|
@@ -53,9 +49,10 @@ exports.createHttpClientTracingMiddleware = ({ tracer, logger, clientName, hasMe
|
|
|
53
49
|
span === null || span === void 0 ? void 0 : span.setTag(Tags_1.OpentracingTags.HTTP_STATUS_CODE, response.status);
|
|
54
50
|
}
|
|
55
51
|
else {
|
|
56
|
-
span === null || span === void 0 ? void 0 : span.setTag("http.no_response" /* HTTP_NO_RESPONSE */, true);
|
|
52
|
+
span === null || span === void 0 ? void 0 : span.setTag("http.no_response" /* CustomHttpTags.HTTP_NO_RESPONSE */, true);
|
|
57
53
|
}
|
|
58
54
|
span === null || span === void 0 ? void 0 : span.finish();
|
|
59
55
|
}
|
|
60
56
|
};
|
|
61
57
|
};
|
|
58
|
+
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
|
|
11
|
+
export type InflightKeyGenerator = (x: RequestConfig) => string;
|
|
12
12
|
interface RequestTracingUserConfig {
|
|
13
13
|
rootSpan?: Span;
|
|
14
14
|
referenceType?: SpanReferenceTypes;
|
|
@@ -44,7 +44,7 @@ export interface RequestConfig extends AxiosRequestConfig, RequestTracingConfig
|
|
|
44
44
|
memoizeable?: boolean;
|
|
45
45
|
inflightKey?: InflightKeyGenerator;
|
|
46
46
|
forceMaxAge?: number;
|
|
47
|
-
responseEncoding?: BufferEncoding
|
|
47
|
+
responseEncoding?: BufferEncoding;
|
|
48
48
|
nullIfNotFound?: boolean;
|
|
49
49
|
ignoreRecorder?: boolean;
|
|
50
50
|
}
|
|
@@ -68,7 +68,7 @@ export interface MiddlewareContext {
|
|
|
68
68
|
inflightHit?: boolean;
|
|
69
69
|
memoizedHit?: boolean;
|
|
70
70
|
}
|
|
71
|
-
export
|
|
71
|
+
export 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 fs_extra_1.pathExistsSync(pathKey);
|
|
19
|
+
return (0, fs_extra_1.pathExistsSync)(pathKey);
|
|
20
20
|
};
|
|
21
21
|
this.getStats = (name = 'disk-cache') => {
|
|
22
22
|
const stats = {
|
|
@@ -41,7 +41,7 @@ class DiskCache {
|
|
|
41
41
|
}
|
|
42
42
|
catch (e) {
|
|
43
43
|
release();
|
|
44
|
-
resolve(
|
|
44
|
+
resolve(null);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
});
|
|
@@ -64,7 +64,7 @@ class DiskCache {
|
|
|
64
64
|
});
|
|
65
65
|
return !failure;
|
|
66
66
|
};
|
|
67
|
-
this.getPathKey = (key) => path_1.join(this.cachePath, key);
|
|
67
|
+
this.getPathKey = (key) => (0, 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?: (
|
|
13
|
-
set: (key: K, value: V, maxAge?: number
|
|
12
|
+
getOrSet: (key: K, fetcher?: () => Promise<FetchResult<V>>) => Promise<V | void>;
|
|
13
|
+
set: (key: K, value: V, maxAge?: number) => 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
|
|
18
|
+
set: (key: string, value: V, maxAge?: number) => Promise<boolean>;
|
|
19
19
|
private getPathKey;
|
|
20
20
|
private deleteFile;
|
|
21
21
|
}
|
|
@@ -53,7 +53,7 @@ class LRUDiskCache {
|
|
|
53
53
|
}
|
|
54
54
|
catch (e) {
|
|
55
55
|
release();
|
|
56
|
-
resolve(
|
|
56
|
+
resolve(null);
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
});
|
|
@@ -93,7 +93,7 @@ class LRUDiskCache {
|
|
|
93
93
|
return !failure;
|
|
94
94
|
};
|
|
95
95
|
this.getPathKey = (key) => {
|
|
96
|
-
return path_1.join(this.cachePath, key);
|
|
96
|
+
return (0, 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 fs_extra_1.remove(pathKey);
|
|
104
|
+
const removePromise = await (0, 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?: (
|
|
9
|
-
set: (key: K, value: V, maxAge?: number
|
|
8
|
+
get: (key: K, fetcher?: () => Promise<FetchResult<V>>) => Promise<V | void>;
|
|
9
|
+
set: (key: K, value: V, maxAge?: number) => Promise<boolean>;
|
|
10
10
|
has: (key: K) => Promise<boolean>;
|
|
11
11
|
getStats: (name?: string) => MultilayerStats;
|
|
12
12
|
private findIndex;
|
|
@@ -8,7 +8,7 @@ class MultilayeredCache {
|
|
|
8
8
|
this.hits = 0;
|
|
9
9
|
this.total = 0;
|
|
10
10
|
this.get = async (key, fetcher) => {
|
|
11
|
-
let value
|
|
11
|
+
let value;
|
|
12
12
|
let maxAge;
|
|
13
13
|
let successIndex = await this.findIndex(async (cache) => {
|
|
14
14
|
const [getValue, hasKey] = await Promise.all([cache.get(key), cache.has(key)]);
|
|
@@ -26,18 +26,18 @@ class MultilayeredCache {
|
|
|
26
26
|
}
|
|
27
27
|
successIndex = Infinity;
|
|
28
28
|
}
|
|
29
|
-
const failedCaches = ramda_1.slice(0, successIndex, this.caches);
|
|
30
|
-
const [firstPromise] = ramda_1.map(cache => cache.set(key, value, maxAge), failedCaches);
|
|
29
|
+
const failedCaches = (0, ramda_1.slice)(0, successIndex, this.caches);
|
|
30
|
+
const [firstPromise] = (0, 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(ramda_1.map(cache => cache.set(key, value, maxAge), this.caches));
|
|
36
|
-
return ramda_1.any(item => item, isSet);
|
|
35
|
+
const isSet = await Promise.all((0, ramda_1.map)(cache => cache.set(key, value, maxAge), this.caches));
|
|
36
|
+
return (0, ramda_1.any)(item => item, isSet);
|
|
37
37
|
};
|
|
38
38
|
this.has = async (key) => {
|
|
39
|
-
const hasList = await Promise.all(ramda_1.map(cache => cache.has(key), this.caches));
|
|
40
|
-
return ramda_1.any(item => item, hasList);
|
|
39
|
+
const hasList = await Promise.all((0, ramda_1.map)(cache => cache.has(key), this.caches));
|
|
40
|
+
return (0, 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,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("./CacheLayer"), exports);
|
package/lib/caches/typings.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type FetchResult<V> = {
|
|
2
2
|
value: V;
|
|
3
3
|
maxAge?: number;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export type DiskStats = {
|
|
6
6
|
hits: number;
|
|
7
7
|
total: number;
|
|
8
8
|
name: string;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type LRUStats = {
|
|
11
11
|
itemCount: number;
|
|
12
12
|
length: number;
|
|
13
13
|
disposedItems: number;
|
|
@@ -17,13 +17,13 @@ export declare type LRUStats = {
|
|
|
17
17
|
name: string;
|
|
18
18
|
total: number;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type MultilayerStats = {
|
|
21
21
|
hitRate: number | undefined;
|
|
22
22
|
hits: number;
|
|
23
23
|
total: number;
|
|
24
24
|
name: string;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export 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
|
|
4
|
+
export 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
|
|
9
|
+
export 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 = routes_1.formatPrivateRoute({ account, workspace, vendor, name, major, protocol });
|
|
20
|
+
baseURL = (0, 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 = routes_1.formatPrivateRoute({ account, workspace, major, name, vendor, protocol, path: '/_v/graphql' });
|
|
20
|
+
baseURL = (0, 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
|
|
6
|
+
status: (tracingConfig?: RequestTracingConfig) => 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
|
|
11
|
+
availability: (app: string, hintIndex: number, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
12
12
|
host: string;
|
|
13
13
|
hostname: string | undefined;
|
|
14
14
|
score: number;
|
|
15
15
|
}>;
|
|
16
|
-
clean: (app: string, tracingConfig?: RequestTracingConfig
|
|
17
|
-
getPinnedDependencies: (tracingConfig?: RequestTracingConfig
|
|
18
|
-
linkApp: (app: string, files: File[], zipOptions?: ZipOptions, params?: RequestParams, tracingConfig?: RequestTracingConfig
|
|
19
|
-
publishApp: (app: string, files: File[], zipOptions?: ZipOptions, params?: RequestParams, tracingConfig?: RequestTracingConfig
|
|
20
|
-
relinkApp: (app: string, changes: Change[], params?: RequestParams, tracingConfig?: RequestTracingConfig
|
|
21
|
-
testApp: (app: string, files: File[], zipOptions?: ZipOptions, params?: RequestParams, tracingConfig?: RequestTracingConfig
|
|
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>;
|
|
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 = archiver_1.default('zip', { zlib });
|
|
86
|
+
const zip = (0, 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
|
|
8
|
+
export 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 = ramda_1.splitEvery(MAX_BATCH_SIZE, allMessages);
|
|
16
|
+
const batchedMessages = (0, 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: ramda_1.values(indexedBatch),
|
|
31
|
+
indexedByFrom: (0, 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(ramda_1.path(['data', 'translate']));
|
|
46
|
+
}).then((0, ramda_1.path)(['data', 'translate']));
|
|
47
47
|
})).then(ramda_1.flatten);
|
|
48
48
|
}
|
|
49
49
|
async translate(args, tracingConfig) {
|