@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
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { IncomingMessage } from 'http';
|
|
4
3
|
import { Readable } from 'stream';
|
|
5
4
|
import { Logger } from './../../service/logger/logger';
|
|
@@ -9,23 +8,23 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
9
8
|
import { InfraClient } from './InfraClient';
|
|
10
9
|
export declare class VBase extends InfraClient {
|
|
11
10
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
12
|
-
getBucket: (bucket: string, tracingConfig?: RequestTracingConfig) => Promise<BucketMetadata>;
|
|
13
|
-
resetBucket: (bucket: string, tracingConfig?: RequestTracingConfig) => Promise<IOResponse<void>>;
|
|
14
|
-
listFiles: (bucket: string, opts?: string | VBaseOptions, tracingConfig?: RequestTracingConfig) => Promise<BucketFileList>;
|
|
15
|
-
getFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<{
|
|
11
|
+
getBucket: (bucket: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<BucketMetadata>;
|
|
12
|
+
resetBucket: (bucket: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<IOResponse<void>>;
|
|
13
|
+
listFiles: (bucket: string, opts?: string | VBaseOptions | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<BucketFileList>;
|
|
14
|
+
getFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
|
|
16
15
|
data: Buffer;
|
|
17
16
|
headers: any;
|
|
18
17
|
}>;
|
|
19
|
-
getJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig) => Promise<T>;
|
|
20
|
-
getRawJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig) => Promise<IOResponse<T>>;
|
|
21
|
-
getFileStream: (bucket: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<IncomingMessage>;
|
|
22
|
-
saveFile: (bucket: string, path: string, stream: Readable, gzip?: boolean, ttl?: number, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<void>;
|
|
23
|
-
getFileMetadata: (bucket: string, path: string, tracingConfig?: RequestTracingConfig) => Promise<IOResponse<void>>;
|
|
24
|
-
saveJSON: <T>(bucket: string, path: string, data: T, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<VBaseSaveResponse>;
|
|
25
|
-
saveZippedContent: (bucket: string, path: string, stream: Readable, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<void>;
|
|
26
|
-
deleteFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig, ifMatch?: string) => Promise<IOResponse<void>>;
|
|
27
|
-
getConflicts: <T>(bucket: string, tracingConfig?: RequestTracingConfig) => Promise<T>;
|
|
28
|
-
resolveConflict: <T>(bucket: string, path: string, content: any, tracingConfig?: RequestTracingConfig) => Promise<T>;
|
|
18
|
+
getJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean | undefined, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
|
|
19
|
+
getRawJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean | undefined, conflictsResolver?: ConflictsResolver<T> | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<IOResponse<T>>;
|
|
20
|
+
getFileStream: (bucket: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<IncomingMessage>;
|
|
21
|
+
saveFile: (bucket: string, path: string, stream: Readable, gzip?: boolean, ttl?: number | undefined, tracingConfig?: RequestTracingConfig | undefined, ifMatch?: string | undefined) => Promise<void>;
|
|
22
|
+
getFileMetadata: (bucket: string, path: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<IOResponse<void>>;
|
|
23
|
+
saveJSON: <T>(bucket: string, path: string, data: T, tracingConfig?: RequestTracingConfig | undefined, ifMatch?: string | undefined) => Promise<VBaseSaveResponse>;
|
|
24
|
+
saveZippedContent: (bucket: string, path: string, stream: Readable, tracingConfig?: RequestTracingConfig | undefined, ifMatch?: string | undefined) => Promise<void>;
|
|
25
|
+
deleteFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig | undefined, ifMatch?: string | undefined) => Promise<IOResponse<void>>;
|
|
26
|
+
getConflicts: <T>(bucket: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
|
|
27
|
+
resolveConflict: <T>(bucket: string, path: string, content: any, tracingConfig?: RequestTracingConfig | undefined) => Promise<T>;
|
|
29
28
|
private saveContent;
|
|
30
29
|
}
|
|
31
30
|
export interface BucketFileList {
|
|
@@ -172,10 +172,10 @@ class VBase extends InfraClient_1.InfraClient {
|
|
|
172
172
|
const params = opts.unzip ? { unzip: opts.unzip } : {};
|
|
173
173
|
const headers = {};
|
|
174
174
|
let finalStream = stream;
|
|
175
|
-
headers['Content-Type'] = mime_types_1.default.contentType(
|
|
175
|
+
headers['Content-Type'] = mime_types_1.default.contentType(path_1.basename(path)) || 'application/octet-stream';
|
|
176
176
|
if (opts.gzip) {
|
|
177
177
|
headers['Content-Encoding'] = 'gzip';
|
|
178
|
-
finalStream = stream.pipe(
|
|
178
|
+
finalStream = stream.pipe(zlib_1.createGzip());
|
|
179
179
|
}
|
|
180
180
|
if (opts.ttl && Number.isInteger(opts.ttl)) {
|
|
181
181
|
headers['X-VTEX-TTL'] = opts.ttl;
|
|
@@ -3,13 +3,13 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
3
3
|
import { InfraClient } from './InfraClient';
|
|
4
4
|
export declare class Workspaces extends InfraClient {
|
|
5
5
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
6
|
-
list: (account: string, tracingConfig?: RequestTracingConfig) => Promise<WorkspaceMetadata[]>;
|
|
7
|
-
get: (account: string, workspace: string, tracingConfig?: RequestTracingConfig) => Promise<WorkspaceMetadata>;
|
|
8
|
-
set: (account: string, workspace: string, metadata: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
9
|
-
create: (account: string, workspace: string, production: boolean, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
10
|
-
delete: (account: string, workspace: string, tracingConfig?: RequestTracingConfig) => Promise<import("../../HttpClient").IOResponse<void>>;
|
|
11
|
-
reset: (account: string, workspace: string, metadata?: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
12
|
-
promote: (account: string, workspace: string, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
6
|
+
list: (account: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<WorkspaceMetadata[]>;
|
|
7
|
+
get: (account: string, workspace: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<WorkspaceMetadata>;
|
|
8
|
+
set: (account: string, workspace: string, metadata: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
|
|
9
|
+
create: (account: string, workspace: string, production: boolean, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
|
|
10
|
+
delete: (account: string, workspace: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<import("../../HttpClient").IOResponse<void>>;
|
|
11
|
+
reset: (account: string, workspace: string, metadata?: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
|
|
12
|
+
promote: (account: string, workspace: string, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
|
|
13
13
|
}
|
|
14
14
|
export interface WorkspaceMetadata {
|
|
15
15
|
name: string;
|
|
@@ -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("./Apps"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InstanceOptions } from '../../HttpClient/typings';
|
|
2
2
|
import { IOContext } from '../../service/worker/runtime/typings';
|
|
3
3
|
import { ExternalClient } from '../external/ExternalClient';
|
|
4
|
-
type Environment = 'stable' | 'beta';
|
|
4
|
+
declare type Environment = 'stable' | 'beta';
|
|
5
5
|
/**
|
|
6
6
|
* Used to perform calls on APIs in the VTEX Janus infrastructure, to which you must declare an outbound policy.
|
|
7
7
|
*
|
|
@@ -11,7 +11,7 @@ const routes = {
|
|
|
11
11
|
topbarData: `${BASE_URL}/site/pvt/newtopbar`,
|
|
12
12
|
};
|
|
13
13
|
const inflightKey = ({ baseURL, url, params }) => {
|
|
14
|
-
return baseURL + url +
|
|
14
|
+
return baseURL + url + qs_1.stringify(params, { arrayFormat: 'repeat', addQueryPrefix: true });
|
|
15
15
|
};
|
|
16
16
|
class LicenseManager extends JanusClient_1.JanusClient {
|
|
17
17
|
getAccountData(VtexIdclientAutCookie, tracingConfig) {
|
|
@@ -21,14 +21,14 @@ export declare class Segment extends JanusClient {
|
|
|
21
21
|
*
|
|
22
22
|
* @memberof Segment
|
|
23
23
|
*/
|
|
24
|
-
getSegment: (tracingConfig?: RequestTracingConfig) => Promise<SegmentData>;
|
|
24
|
+
getSegment: (tracingConfig?: RequestTracingConfig | undefined) => Promise<SegmentData>;
|
|
25
25
|
/**
|
|
26
26
|
* Get the segment data from this specific segment token
|
|
27
27
|
*
|
|
28
28
|
* @memberof Segment
|
|
29
29
|
*/
|
|
30
|
-
getSegmentByToken: (token: string | null, tracingConfig?: RequestTracingConfig) => Promise<SegmentData>;
|
|
31
|
-
getOrCreateSegment: (query?: Record<string, string
|
|
30
|
+
getSegmentByToken: (token: string | null, tracingConfig?: RequestTracingConfig | undefined) => Promise<SegmentData>;
|
|
31
|
+
getOrCreateSegment: (query?: Record<string, string> | undefined, token?: string | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
|
|
32
32
|
segmentData: SegmentData;
|
|
33
33
|
segmentToken: string | null;
|
|
34
34
|
}>;
|
|
@@ -36,13 +36,13 @@ class Segment extends JanusClient_1.JanusClient {
|
|
|
36
36
|
*
|
|
37
37
|
* @memberof Segment
|
|
38
38
|
*/
|
|
39
|
-
this.getSegment = (tracingConfig) => this.rawSegment(this.context.segmentToken, undefined, tracingConfig).then(
|
|
39
|
+
this.getSegment = (tracingConfig) => this.rawSegment(this.context.segmentToken, undefined, tracingConfig).then(ramda_1.prop('data'));
|
|
40
40
|
/**
|
|
41
41
|
* Get the segment data from this specific segment token
|
|
42
42
|
*
|
|
43
43
|
* @memberof Segment
|
|
44
44
|
*/
|
|
45
|
-
this.getSegmentByToken = (token, tracingConfig) => this.rawSegment(token, undefined, tracingConfig).then(
|
|
45
|
+
this.getSegmentByToken = (token, tracingConfig) => this.rawSegment(token, undefined, tracingConfig).then(ramda_1.prop('data'));
|
|
46
46
|
this.getOrCreateSegment = async (query, token, tracingConfig) => {
|
|
47
47
|
const { data: segmentData, headers } = await this.rawSegment(token, query, tracingConfig);
|
|
48
48
|
return {
|
|
@@ -4,12 +4,12 @@ export declare class Session extends JanusClient {
|
|
|
4
4
|
/**
|
|
5
5
|
* Get the session data using the given token
|
|
6
6
|
*/
|
|
7
|
-
getSession: (token: string, items: string[], tracingConfig?: RequestTracingConfig) => Promise<{
|
|
7
|
+
getSession: (token: string, items: string[], tracingConfig?: RequestTracingConfig | undefined) => Promise<{
|
|
8
8
|
sessionData: any;
|
|
9
9
|
sessionToken: string;
|
|
10
10
|
}>;
|
|
11
11
|
/**
|
|
12
12
|
* Update the public portion of this session
|
|
13
13
|
*/
|
|
14
|
-
updateSession: (key: string, value: any, items: string[], token: any, tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
14
|
+
updateSession: (key: string, value: any, items: string[], token: any, tracingConfig?: RequestTracingConfig | undefined) => Promise<void>;
|
|
15
15
|
}
|
|
@@ -25,5 +25,5 @@ export interface Tenant {
|
|
|
25
25
|
}
|
|
26
26
|
export declare class TenantClient extends JanusClient {
|
|
27
27
|
constructor(ctx: IOContext, opts?: InstanceOptions);
|
|
28
|
-
info: (config?: RequestConfig) => Promise<Tenant>;
|
|
28
|
+
info: (config?: RequestConfig | undefined) => Promise<Tenant>;
|
|
29
29
|
}
|
|
@@ -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("./JanusClient"), exports);
|
package/lib/constants.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const COLOSSUS_ROUTE_ID_HEADER = "x-colossus-route-id";
|
|
|
30
30
|
export declare const COLOSSUS_PARAMS_HEADER = "x-colossus-params";
|
|
31
31
|
export declare const TRACE_ID_HEADER = "x-trace-id";
|
|
32
32
|
export declare const PROVIDER_HEADER = "x-vtex-provider";
|
|
33
|
-
export type VaryHeaders = typeof SEGMENT_HEADER | typeof SESSION_HEADER | typeof PRODUCT_HEADER | typeof LOCALE_HEADER;
|
|
33
|
+
export declare type VaryHeaders = typeof SEGMENT_HEADER | typeof SESSION_HEADER | typeof PRODUCT_HEADER | typeof LOCALE_HEADER;
|
|
34
34
|
export declare const BODY_HASH = "__graphqlBodyHash";
|
|
35
35
|
export declare const UP_SIGNAL = "UP";
|
|
36
36
|
export declare const MAX_AGE: {
|
package/lib/constants.js
CHANGED
|
@@ -50,7 +50,7 @@ exports.REGION = process.env.VTEX_REGION;
|
|
|
50
50
|
exports.PUBLIC_ENDPOINT = process.env.VTEX_PUBLIC_ENDPOINT || 'myvtex.com';
|
|
51
51
|
exports.APP = {
|
|
52
52
|
ID: process.env.VTEX_APP_ID,
|
|
53
|
-
MAJOR: process.env.VTEX_APP_VERSION ?
|
|
53
|
+
MAJOR: process.env.VTEX_APP_VERSION ? app_1.versionToMajor(process.env.VTEX_APP_VERSION) : '',
|
|
54
54
|
NAME: process.env.VTEX_APP_NAME,
|
|
55
55
|
VENDOR: process.env.VTEX_APP_VENDOR,
|
|
56
56
|
VERSION: process.env.VTEX_APP_VERSION,
|
|
@@ -26,7 +26,7 @@ class ResolverError extends Error {
|
|
|
26
26
|
this.level = logger_1.LogLevel.Error;
|
|
27
27
|
if (typeof messageOrError === 'object') {
|
|
28
28
|
// Copy original error properties without circular references
|
|
29
|
-
Object.assign(this,
|
|
29
|
+
Object.assign(this, error_1.cleanError(messageOrError));
|
|
30
30
|
}
|
|
31
31
|
if (typeof messageOrError === 'string' || !messageOrError.stack) {
|
|
32
32
|
Error.captureStackTrace(this, ResolverError);
|
package/lib/errors/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("./AuthenticationError"), exports);
|
package/lib/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
|
process.env.FORCE_COLOR = '1';
|
|
@@ -14,7 +14,7 @@ export declare class MetricsAccumulator {
|
|
|
14
14
|
private cacheMap;
|
|
15
15
|
private onFlushMetrics;
|
|
16
16
|
constructor();
|
|
17
|
-
batchMetric: (name: string, timeMillis?: number, extensions?: Record<string, string | number>) => void;
|
|
17
|
+
batchMetric: (name: string, timeMillis?: number | undefined, extensions?: Record<string, string | number> | undefined) => void;
|
|
18
18
|
/**
|
|
19
19
|
* Batches a named metric which took `diffNs`.
|
|
20
20
|
*
|
|
@@ -24,7 +24,7 @@ export declare class MetricsAccumulator {
|
|
|
24
24
|
*
|
|
25
25
|
* @see https://nodejs.org/api/process.html#process_process_hrtime_time
|
|
26
26
|
*/
|
|
27
|
-
batch: (name: string, diffNs?: [number, number], extensions?: Record<string, string | number>) => void;
|
|
27
|
+
batch: (name: string, diffNs?: [number, number] | undefined, extensions?: Record<string, string | number> | undefined) => void;
|
|
28
28
|
addOnFlushMetric: (metricFn: () => Metric | Metric[]) => void;
|
|
29
29
|
trackCache: (name: string, cacheInstance: GetStats) => void;
|
|
30
30
|
statusTrack: () => EnvMetric[];
|
|
@@ -56,7 +56,7 @@ class MetricsAccumulator {
|
|
|
56
56
|
* @see https://nodejs.org/api/process.html#process_process_hrtime_time
|
|
57
57
|
*/
|
|
58
58
|
this.batch = (name, diffNs, extensions) => {
|
|
59
|
-
this.batchMetric(name, diffNs ?
|
|
59
|
+
this.batchMetric(name, diffNs ? time_1.hrToMillis(diffNs) : undefined, extensions);
|
|
60
60
|
};
|
|
61
61
|
this.addOnFlushMetric = (metricFn) => {
|
|
62
62
|
this.onFlushMetrics.push(metricFn);
|
|
@@ -72,10 +72,10 @@ class MetricsAccumulator {
|
|
|
72
72
|
name: key,
|
|
73
73
|
count: value.length,
|
|
74
74
|
max: Math.max(...value),
|
|
75
|
-
mean:
|
|
76
|
-
median:
|
|
77
|
-
percentile95:
|
|
78
|
-
percentile99:
|
|
75
|
+
mean: stats_lite_1.mean(value),
|
|
76
|
+
median: stats_lite_1.median(value),
|
|
77
|
+
percentile95: stats_lite_1.percentile(value, 0.95),
|
|
78
|
+
percentile99: stats_lite_1.percentile(value, 0.99),
|
|
79
79
|
production,
|
|
80
80
|
...this.extensions[key],
|
|
81
81
|
};
|
|
@@ -89,7 +89,7 @@ class MetricsAccumulator {
|
|
|
89
89
|
production,
|
|
90
90
|
});
|
|
91
91
|
this.flushMetrics = () => {
|
|
92
|
-
const aggregateMetrics =
|
|
92
|
+
const aggregateMetrics = ramda_1.values(ramda_1.mapObjIndexed(this.metricToAggregate, this.metricsMillis));
|
|
93
93
|
const systemMetrics = [
|
|
94
94
|
{
|
|
95
95
|
...cpuUsage(),
|
|
@@ -112,9 +112,9 @@ class MetricsAccumulator {
|
|
|
112
112
|
production,
|
|
113
113
|
},
|
|
114
114
|
];
|
|
115
|
-
const onFlushMetrics =
|
|
116
|
-
const envFlushMetric =
|
|
117
|
-
const cacheMetrics =
|
|
115
|
+
const onFlushMetrics = ramda_1.flatten(ramda_1.map(getMetric => getMetric(), this.onFlushMetrics));
|
|
116
|
+
const envFlushMetric = ramda_1.map(ramda_1.assoc('production', production), onFlushMetrics);
|
|
117
|
+
const cacheMetrics = ramda_1.values(ramda_1.mapObjIndexed(this.cacheToMetric, this.cacheMap));
|
|
118
118
|
return [...systemMetrics, ...aggregateMetrics, ...envFlushMetric, ...cacheMetrics];
|
|
119
119
|
};
|
|
120
120
|
this.metricsMillis = {};
|
package/lib/responses.d.ts
CHANGED
|
@@ -50,13 +50,13 @@ export interface AppBundleResponse {
|
|
|
50
50
|
message: string;
|
|
51
51
|
id: string;
|
|
52
52
|
}
|
|
53
|
-
export type AppBundlePublished = AppBundleResponse & {
|
|
53
|
+
export declare type AppBundlePublished = AppBundleResponse & {
|
|
54
54
|
bundleSize?: number;
|
|
55
55
|
};
|
|
56
|
-
export type AppBundleLinked = AppBundleResponse & {
|
|
56
|
+
export declare type AppBundleLinked = AppBundleResponse & {
|
|
57
57
|
bundleSize?: number;
|
|
58
58
|
};
|
|
59
|
-
export type AppState = 'stable' | 'releaseCandidate';
|
|
59
|
+
export declare type AppState = 'stable' | 'releaseCandidate';
|
|
60
60
|
export interface HouseKeeperState {
|
|
61
61
|
infra: string[];
|
|
62
62
|
edition: string[];
|
|
@@ -76,5 +76,5 @@ export interface HousekeeperStatesAndUpdates {
|
|
|
76
76
|
state: HouseKeeperState;
|
|
77
77
|
updates: HouseKeeperUpdates;
|
|
78
78
|
}
|
|
79
|
-
export type VBaseSaveResponse = FileListItem[];
|
|
79
|
+
export declare type VBaseSaveResponse = FileListItem[];
|
|
80
80
|
export {};
|
package/lib/service/index.js
CHANGED
|
@@ -3,33 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.startApp = void 0;
|
|
7
7
|
const cluster_1 = __importDefault(require("cluster"));
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const loaders_1 = require("./loaders");
|
|
10
10
|
const logger_1 = require("./logger");
|
|
11
11
|
const master_1 = require("./master");
|
|
12
12
|
const worker_1 = require("./worker");
|
|
13
|
-
|
|
14
|
-
const serviceJSON =
|
|
13
|
+
exports.startApp = () => {
|
|
14
|
+
const serviceJSON = loaders_1.getServiceJSON();
|
|
15
15
|
try {
|
|
16
16
|
// if it is a master process then call setting up worker process
|
|
17
17
|
if (cluster_1.default.isMaster) {
|
|
18
|
-
|
|
18
|
+
master_1.startMaster(serviceJSON);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
// to setup server configurations and share port address for incoming requests
|
|
22
|
-
|
|
22
|
+
worker_1.startWorker(serviceJSON).listen(constants_1.HTTP_SERVER_PORT);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
catch (err) {
|
|
26
26
|
if (!(err instanceof Error)) {
|
|
27
27
|
throw err;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
logger_1.logOnceToDevConsole(err.stack || err.message, logger_1.LogLevel.Error);
|
|
30
30
|
process.exit(2);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
exports.startApp = startApp;
|
|
34
33
|
var loaders_2 = require("./loaders");
|
|
35
34
|
Object.defineProperty(exports, "appPath", { enumerable: true, get: function () { return loaders_2.appPath; } });
|
package/lib/service/loaders.js
CHANGED
|
@@ -5,9 +5,9 @@ const os_1 = require("os");
|
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const IOClients_1 = require("../clients/IOClients");
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
|
-
exports.appPath =
|
|
9
|
-
exports.bundlePath =
|
|
10
|
-
exports.serviceJsonPath =
|
|
8
|
+
exports.appPath = path_1.join(process.cwd(), './service/src/node/');
|
|
9
|
+
exports.bundlePath = path_1.join(exports.appPath, 'index');
|
|
10
|
+
exports.serviceJsonPath = path_1.join(process.cwd(), './service/service.json');
|
|
11
11
|
const getWorkers = (workers) => {
|
|
12
12
|
// We need to have only one worker while linking so the debugger
|
|
13
13
|
// works properly
|
|
@@ -15,18 +15,17 @@ const getWorkers = (workers) => {
|
|
|
15
15
|
return 1;
|
|
16
16
|
}
|
|
17
17
|
// If user didn't set workers property, let's use the cpu count
|
|
18
|
-
const workersFromUser = workers && Number.isInteger(workers) ? workers :
|
|
18
|
+
const workersFromUser = workers && Number.isInteger(workers) ? workers : os_1.cpus().length;
|
|
19
19
|
// never spawns more than MAX_WORKERS
|
|
20
20
|
return Math.min(workersFromUser, constants_1.MAX_WORKERS);
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
exports.getServiceJSON = () => {
|
|
23
23
|
const service = require(exports.serviceJsonPath);
|
|
24
24
|
return {
|
|
25
25
|
...service,
|
|
26
26
|
workers: getWorkers(service.workers),
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
exports.getServiceJSON = getServiceJSON;
|
|
30
29
|
const defaultClients = {
|
|
31
30
|
options: {
|
|
32
31
|
messages: {
|
|
@@ -41,7 +40,7 @@ const defaultClients = {
|
|
|
41
40
|
},
|
|
42
41
|
},
|
|
43
42
|
};
|
|
44
|
-
|
|
43
|
+
exports.getService = () => {
|
|
45
44
|
var _a;
|
|
46
45
|
const { default: service } = require(exports.bundlePath);
|
|
47
46
|
const { config: { clients } } = service;
|
|
@@ -54,4 +53,3 @@ const getService = () => {
|
|
|
54
53
|
};
|
|
55
54
|
return service;
|
|
56
55
|
};
|
|
57
|
-
exports.getService = getService;
|
|
@@ -7,25 +7,23 @@ const history = new caches_1.LRUCache({
|
|
|
7
7
|
max: 42,
|
|
8
8
|
});
|
|
9
9
|
exports.LOG_ONCE = 'logOnce';
|
|
10
|
-
|
|
11
|
-
exports.
|
|
12
|
-
const log = (message, level) => {
|
|
10
|
+
exports.isLog = (message) => (message === null || message === void 0 ? void 0 : message.cmd) === exports.LOG_ONCE;
|
|
11
|
+
exports.log = (message, level) => {
|
|
13
12
|
const logger = console[level];
|
|
14
13
|
if (typeof logger === 'function') {
|
|
15
14
|
logger(message);
|
|
16
15
|
}
|
|
17
16
|
};
|
|
18
|
-
exports.log = log;
|
|
19
17
|
// Since we are now using clusters, if we simply console.log something,
|
|
20
18
|
// it may overwhelm the programmer's console with lots of repeated info.
|
|
21
19
|
// This function should be used when you want to warn about something
|
|
22
20
|
// only once
|
|
23
|
-
|
|
21
|
+
exports.logOnceToDevConsole = (message, level) => {
|
|
24
22
|
const strigified = JSON.stringify(message);
|
|
25
23
|
if (!history.has(strigified)) {
|
|
26
24
|
history.set(strigified, true);
|
|
27
25
|
if (cluster_1.isMaster) {
|
|
28
|
-
|
|
26
|
+
exports.log(message, level);
|
|
29
27
|
}
|
|
30
28
|
else if (cluster_1.isWorker && process.send) {
|
|
31
29
|
const logMessage = {
|
|
@@ -37,4 +35,3 @@ const logOnceToDevConsole = (message, level) => {
|
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
};
|
|
40
|
-
exports.logOnceToDevConsole = logOnceToDevConsole;
|
|
@@ -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("./console"), exports);
|
|
@@ -22,8 +22,8 @@ class Logger {
|
|
|
22
22
|
this.error = (error) => this.log(error, LogLevel.Error);
|
|
23
23
|
this.log = (message, level) => {
|
|
24
24
|
var _a;
|
|
25
|
-
const data = message ?
|
|
26
|
-
|
|
25
|
+
const data = message ? error_1.cleanError(message) : EMPTY_MESSAGE;
|
|
26
|
+
log_1.cleanLog(data);
|
|
27
27
|
/* tslint:disable:object-literal-sort-keys */
|
|
28
28
|
const inflatedLog = {
|
|
29
29
|
__VTEX_IO_LOG: true,
|
|
@@ -21,11 +21,11 @@ class MetricsLogger {
|
|
|
21
21
|
// private attributes
|
|
22
22
|
//////////////////////
|
|
23
23
|
let samples = {};
|
|
24
|
-
let lastCpu =
|
|
24
|
+
let lastCpu = diff_1.cpuSnapshot();
|
|
25
25
|
//////////////////////
|
|
26
26
|
// private methods definitions
|
|
27
27
|
//////////////////////
|
|
28
|
-
const summaries =
|
|
28
|
+
const summaries = ramda_1.compose(ramda_1.reject(ramda_1.isNil), ramda_1.values, ramda_1.mapObjIndexed(getSummary));
|
|
29
29
|
function getDefaultStoredashProperties() {
|
|
30
30
|
return {
|
|
31
31
|
Count: 1,
|
|
@@ -47,8 +47,8 @@ class MetricsLogger {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
function getCpuUsage() {
|
|
50
|
-
const cpu =
|
|
51
|
-
const cpuDiff =
|
|
50
|
+
const cpu = diff_1.cpuSnapshot();
|
|
51
|
+
const cpuDiff = diff_1.snapshotDiff(cpu, lastCpu);
|
|
52
52
|
lastCpu = cpu;
|
|
53
53
|
const metric = {
|
|
54
54
|
Data: {
|
|
@@ -103,7 +103,7 @@ class MetricsLogger {
|
|
|
103
103
|
return false;
|
|
104
104
|
}
|
|
105
105
|
try {
|
|
106
|
-
|
|
106
|
+
fast_json_stable_stringify_1.default(key);
|
|
107
107
|
}
|
|
108
108
|
catch {
|
|
109
109
|
return false;
|
|
@@ -111,17 +111,17 @@ class MetricsLogger {
|
|
|
111
111
|
return true;
|
|
112
112
|
}
|
|
113
113
|
function getStrKey(key) {
|
|
114
|
-
return
|
|
114
|
+
return fast_json_stable_stringify_1.default(key);
|
|
115
115
|
}
|
|
116
116
|
function getNumericSummary(vals) {
|
|
117
117
|
return {
|
|
118
118
|
count: vals.length,
|
|
119
119
|
max: Math.max(...vals),
|
|
120
|
-
median:
|
|
120
|
+
median: stats_lite_1.median(vals),
|
|
121
121
|
min: Math.min(...vals),
|
|
122
|
-
percentile95:
|
|
123
|
-
percentile99:
|
|
124
|
-
sum:
|
|
122
|
+
percentile95: stats_lite_1.percentile(vals, 0.95),
|
|
123
|
+
percentile99: stats_lite_1.percentile(vals, 0.99),
|
|
124
|
+
sum: stats_lite_1.sum(vals),
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
//////////////////////
|
package/lib/service/master.js
CHANGED
|
@@ -12,12 +12,12 @@ const listeners_1 = require("./worker/listeners");
|
|
|
12
12
|
const statusTrack_1 = require("./worker/runtime/statusTrack");
|
|
13
13
|
let handledSignal;
|
|
14
14
|
const onMessage = (worker, message) => {
|
|
15
|
-
if (
|
|
16
|
-
|
|
15
|
+
if (logger_1.isLog(message)) {
|
|
16
|
+
logger_1.logOnceToDevConsole(message.message, message.level);
|
|
17
17
|
}
|
|
18
|
-
else if (
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
else if (statusTrack_1.isStatusTrackBroadcast(message)) {
|
|
19
|
+
statusTrack_1.trackStatus();
|
|
20
|
+
statusTrack_1.broadcastStatusTrack();
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
23
|
listeners_1.logger.warn({
|
|
@@ -65,7 +65,7 @@ const handleSignal = (timeout) => (signal) => {
|
|
|
65
65
|
process.exit(os_1.constants.signals[signal]);
|
|
66
66
|
}, waitTimeToForceKill);
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
exports.startMaster = (service) => {
|
|
69
69
|
const { workers: numWorkers, timeout = GRACEFULLY_SHUTDOWN_TIMEOUT_S } = service;
|
|
70
70
|
if (service.deterministicVary) {
|
|
71
71
|
process.env.DETERMINISTIC_VARY = 'true';
|
|
@@ -86,4 +86,3 @@ const startMaster = (service) => {
|
|
|
86
86
|
process.on('SIGINT', handleSignal(SIGINT_TIMEOUT_S));
|
|
87
87
|
process.on('SIGTERM', handleSignal(shutdownTimeout));
|
|
88
88
|
};
|
|
89
|
-
exports.startMaster = startMaster;
|