@vtex/api 6.48.1-beta.3 → 6.48.1-beta.4
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 +38 -36
- 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 +12 -9
- 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 -6
- package/lib/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.js +9 -7
- package/lib/HttpClient/middlewares/tracing.js +11 -14
- package/lib/HttpClient/typings.d.ts +2 -2
- 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 +6 -6
- 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 +2 -2
- 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/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 +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 +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 +26 -4
|
@@ -3,8 +3,8 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
3
3
|
import { InfraClient } from './InfraClient';
|
|
4
4
|
export declare class Sphinx extends InfraClient {
|
|
5
5
|
constructor(ioContext: IOContext, opts?: InstanceOptions);
|
|
6
|
-
validatePolicies: (policies: PolicyRequest[], tracingConfig?: RequestTracingConfig
|
|
7
|
-
isAdmin: (email: string, tracingConfig?: RequestTracingConfig
|
|
6
|
+
validatePolicies: (policies: PolicyRequest[], tracingConfig?: RequestTracingConfig) => Promise<void>;
|
|
7
|
+
isAdmin: (email: string, tracingConfig?: RequestTracingConfig) => Promise<boolean>;
|
|
8
8
|
}
|
|
9
9
|
export interface PolicyRequest {
|
|
10
10
|
name: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { IncomingMessage } from 'http';
|
|
3
4
|
import { Readable } from 'stream';
|
|
4
5
|
import { Logger } from './../../service/logger/logger';
|
|
@@ -8,23 +9,23 @@ import { IOContext } from '../../service/worker/runtime/typings';
|
|
|
8
9
|
import { InfraClient } from './InfraClient';
|
|
9
10
|
export declare class VBase extends InfraClient {
|
|
10
11
|
constructor(context: IOContext, options?: InstanceOptions);
|
|
11
|
-
getBucket: (bucket: string, tracingConfig?: RequestTracingConfig
|
|
12
|
-
resetBucket: (bucket: string, tracingConfig?: RequestTracingConfig
|
|
13
|
-
listFiles: (bucket: string, opts?: string | VBaseOptions
|
|
14
|
-
getFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig
|
|
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<{
|
|
15
16
|
data: Buffer;
|
|
16
17
|
headers: any;
|
|
17
18
|
}>;
|
|
18
|
-
getJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean
|
|
19
|
-
getRawJSON: <T>(bucket: string, path: string, nullIfNotFound?: boolean
|
|
20
|
-
getFileStream: (bucket: string, path: string, tracingConfig?: RequestTracingConfig
|
|
21
|
-
saveFile: (bucket: string, path: string, stream: Readable, gzip?: boolean, ttl?: number
|
|
22
|
-
getFileMetadata: (bucket: string, path: string, tracingConfig?: RequestTracingConfig
|
|
23
|
-
saveJSON: <T>(bucket: string, path: string, data: T, tracingConfig?: RequestTracingConfig
|
|
24
|
-
saveZippedContent: (bucket: string, path: string, stream: Readable, tracingConfig?: RequestTracingConfig
|
|
25
|
-
deleteFile: (bucket: string, path: string, tracingConfig?: RequestTracingConfig
|
|
26
|
-
getConflicts: <T>(bucket: string, tracingConfig?: RequestTracingConfig
|
|
27
|
-
resolveConflict: <T>(bucket: string, path: string, content: any, tracingConfig?: RequestTracingConfig
|
|
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>;
|
|
28
29
|
private saveContent;
|
|
29
30
|
}
|
|
30
31
|
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(path_1.basename(path)) || 'application/octet-stream';
|
|
175
|
+
headers['Content-Type'] = mime_types_1.default.contentType((0, path_1.basename)(path)) || 'application/octet-stream';
|
|
176
176
|
if (opts.gzip) {
|
|
177
177
|
headers['Content-Encoding'] = 'gzip';
|
|
178
|
-
finalStream = stream.pipe(zlib_1.createGzip());
|
|
178
|
+
finalStream = stream.pipe((0, 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
|
|
7
|
-
get: (account: string, workspace: string, tracingConfig?: RequestTracingConfig
|
|
8
|
-
set: (account: string, workspace: string, metadata: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig
|
|
9
|
-
create: (account: string, workspace: string, production: boolean, tracingConfig?: RequestTracingConfig
|
|
10
|
-
delete: (account: string, workspace: string, tracingConfig?: RequestTracingConfig
|
|
11
|
-
reset: (account: string, workspace: string, metadata?: Partial<WorkspaceMetadata>, tracingConfig?: RequestTracingConfig
|
|
12
|
-
promote: (account: string, workspace: string, tracingConfig?: RequestTracingConfig
|
|
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>;
|
|
13
13
|
}
|
|
14
14
|
export interface WorkspaceMetadata {
|
|
15
15
|
name: string;
|
|
@@ -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("./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
|
-
|
|
4
|
+
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 + qs_1.stringify(params, { arrayFormat: 'repeat', addQueryPrefix: true });
|
|
14
|
+
return baseURL + url + (0, 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
|
|
24
|
+
getSegment: (tracingConfig?: RequestTracingConfig) => 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
|
|
31
|
-
getOrCreateSegment: (query?: Record<string, string
|
|
30
|
+
getSegmentByToken: (token: string | null, tracingConfig?: RequestTracingConfig) => Promise<SegmentData>;
|
|
31
|
+
getOrCreateSegment: (query?: Record<string, string>, token?: string, tracingConfig?: RequestTracingConfig) => 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(ramda_1.prop('data'));
|
|
39
|
+
this.getSegment = (tracingConfig) => this.rawSegment(this.context.segmentToken, undefined, tracingConfig).then((0, 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(ramda_1.prop('data'));
|
|
45
|
+
this.getSegmentByToken = (token, tracingConfig) => this.rawSegment(token, undefined, tracingConfig).then((0, 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
|
|
7
|
+
getSession: (token: string, items: string[], tracingConfig?: RequestTracingConfig) => 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
|
|
14
|
+
updateSession: (key: string, value: any, items: string[], token: any, tracingConfig?: RequestTracingConfig) => 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
|
|
28
|
+
info: (config?: RequestConfig) => Promise<Tenant>;
|
|
29
29
|
}
|
|
@@ -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("./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
|
|
33
|
+
export 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: {
|
|
@@ -57,3 +57,4 @@ export declare const WORKSPACE: string;
|
|
|
57
57
|
export declare const PRODUCTION: boolean;
|
|
58
58
|
export declare const INSPECT_DEBUGGER_PORT = 5858;
|
|
59
59
|
export declare const cancellableMethods: Set<string>;
|
|
60
|
+
export declare const LOG_CLIENT_INIT_TIMEOUT_MS = 5000;
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cancellableMethods = exports.INSPECT_DEBUGGER_PORT = exports.PRODUCTION = exports.WORKSPACE = exports.ACCOUNT = exports.NODE_ENV = exports.APP = exports.PUBLIC_ENDPOINT = exports.REGION = exports.LINKED = exports.MAX_WORKERS = exports.HTTP_SERVER_PORT = exports.MAX_AGE = exports.UP_SIGNAL = exports.BODY_HASH = exports.PROVIDER_HEADER = exports.TRACE_ID_HEADER = exports.COLOSSUS_PARAMS_HEADER = exports.COLOSSUS_ROUTE_ID_HEADER = exports.COLOSSUS_ROUTE_DECLARER_HEADER = exports.EVENT_HANDLER_ID_HEADER = exports.EVENT_SUBJECT_HEADER = exports.EVENT_SENDER_HEADER = exports.EVENT_KEY_HEADER = exports.WORKSPACE_HEADER = exports.WORKSPACE_IS_PRODUCTION_HEADER = exports.PLATFORM_HEADER = exports.OPERATION_ID_HEADER = exports.ROUTER_CACHE_HEADER = exports.REQUEST_ID_HEADER = exports.CREDENTIAL_HEADER = exports.ACCOUNT_HEADER = exports.ETAG_HEADER = exports.META_HEADER_BUCKET = exports.META_HEADER = exports.BINDING_HEADER = exports.TENANT_HEADER = exports.FORWARDED_HOST_HEADER = exports.LOCALE_HEADER = exports.PRODUCT_HEADER = exports.SESSION_HEADER = exports.SEGMENT_HEADER = exports.CACHE_CONTROL_HEADER = exports.PID = exports.IS_IO = exports.DEFAULT_WORKSPACE = exports.NODE_VTEX_API_VERSION = void 0;
|
|
3
|
+
exports.LOG_CLIENT_INIT_TIMEOUT_MS = exports.cancellableMethods = exports.INSPECT_DEBUGGER_PORT = exports.PRODUCTION = exports.WORKSPACE = exports.ACCOUNT = exports.NODE_ENV = exports.APP = exports.PUBLIC_ENDPOINT = exports.REGION = exports.LINKED = exports.MAX_WORKERS = exports.HTTP_SERVER_PORT = exports.MAX_AGE = exports.UP_SIGNAL = exports.BODY_HASH = exports.PROVIDER_HEADER = exports.TRACE_ID_HEADER = exports.COLOSSUS_PARAMS_HEADER = exports.COLOSSUS_ROUTE_ID_HEADER = exports.COLOSSUS_ROUTE_DECLARER_HEADER = exports.EVENT_HANDLER_ID_HEADER = exports.EVENT_SUBJECT_HEADER = exports.EVENT_SENDER_HEADER = exports.EVENT_KEY_HEADER = exports.WORKSPACE_HEADER = exports.WORKSPACE_IS_PRODUCTION_HEADER = exports.PLATFORM_HEADER = exports.OPERATION_ID_HEADER = exports.ROUTER_CACHE_HEADER = exports.REQUEST_ID_HEADER = exports.CREDENTIAL_HEADER = exports.ACCOUNT_HEADER = exports.ETAG_HEADER = exports.META_HEADER_BUCKET = exports.META_HEADER = exports.BINDING_HEADER = exports.TENANT_HEADER = exports.FORWARDED_HOST_HEADER = exports.LOCALE_HEADER = exports.PRODUCT_HEADER = exports.SESSION_HEADER = exports.SEGMENT_HEADER = exports.CACHE_CONTROL_HEADER = exports.PID = exports.IS_IO = exports.DEFAULT_WORKSPACE = exports.NODE_VTEX_API_VERSION = void 0;
|
|
4
4
|
const app_1 = require("./utils/app");
|
|
5
5
|
// tslint:disable-next-line
|
|
6
6
|
const pkg = require('../package.json');
|
|
@@ -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 ? app_1.versionToMajor(process.env.VTEX_APP_VERSION) : '',
|
|
53
|
+
MAJOR: process.env.VTEX_APP_VERSION ? (0, 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,
|
|
@@ -64,3 +64,4 @@ exports.WORKSPACE = process.env.VTEX_WORKSPACE;
|
|
|
64
64
|
exports.PRODUCTION = process.env.VTEX_PRODUCTION === 'true';
|
|
65
65
|
exports.INSPECT_DEBUGGER_PORT = 5858;
|
|
66
66
|
exports.cancellableMethods = new Set(['GET', 'OPTIONS', 'HEAD']);
|
|
67
|
+
exports.LOG_CLIENT_INIT_TIMEOUT_MS = 5000;
|
|
@@ -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, error_1.cleanError(messageOrError));
|
|
29
|
+
Object.assign(this, (0, 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,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("./AuthenticationError"), exports);
|
package/lib/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
|
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
|
|
17
|
+
batchMetric: (name: string, timeMillis?: number, extensions?: Record<string, string | number>) => 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]
|
|
27
|
+
batch: (name: string, diffNs?: [number, number], extensions?: Record<string, string | number>) => 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 ? time_1.hrToMillis(diffNs) : undefined, extensions);
|
|
59
|
+
this.batchMetric(name, diffNs ? (0, 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: 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),
|
|
75
|
+
mean: (0, stats_lite_1.mean)(value),
|
|
76
|
+
median: (0, stats_lite_1.median)(value),
|
|
77
|
+
percentile95: (0, stats_lite_1.percentile)(value, 0.95),
|
|
78
|
+
percentile99: (0, 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 = ramda_1.values(ramda_1.mapObjIndexed(this.metricToAggregate, this.metricsMillis));
|
|
92
|
+
const aggregateMetrics = (0, ramda_1.values)((0, 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 = 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));
|
|
115
|
+
const onFlushMetrics = (0, ramda_1.flatten)((0, ramda_1.map)(getMetric => getMetric(), this.onFlushMetrics));
|
|
116
|
+
const envFlushMetric = (0, ramda_1.map)((0, ramda_1.assoc)('production', production), onFlushMetrics);
|
|
117
|
+
const cacheMetrics = (0, ramda_1.values)((0, 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
|
|
53
|
+
export type AppBundlePublished = AppBundleResponse & {
|
|
54
54
|
bundleSize?: number;
|
|
55
55
|
};
|
|
56
|
-
export
|
|
56
|
+
export type AppBundleLinked = AppBundleResponse & {
|
|
57
57
|
bundleSize?: number;
|
|
58
58
|
};
|
|
59
|
-
export
|
|
59
|
+
export 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
|
|
79
|
+
export type VBaseSaveResponse = FileListItem[];
|
|
80
80
|
export {};
|
package/lib/service/index.js
CHANGED
|
@@ -3,32 +3,30 @@ 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.startApp = void 0;
|
|
6
|
+
exports.appPath = 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 = loaders_1.getServiceJSON();
|
|
13
|
+
const startApp = () => {
|
|
14
|
+
const serviceJSON = (0, 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
|
-
master_1.startMaster(serviceJSON);
|
|
18
|
+
(0, master_1.startMaster)(serviceJSON);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
// to setup server configurations and share port address for incoming requests
|
|
22
|
-
worker_1.startWorker(serviceJSON).listen(constants_1.HTTP_SERVER_PORT);
|
|
22
|
+
(0, worker_1.startWorker)(serviceJSON).listen(constants_1.HTTP_SERVER_PORT);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
catch (err) {
|
|
26
|
-
|
|
27
|
-
throw err;
|
|
28
|
-
}
|
|
29
|
-
logger_1.logOnceToDevConsole(err.stack || err.message, logger_1.LogLevel.Error);
|
|
26
|
+
(0, logger_1.logOnceToDevConsole)(err.stack || err.message, logger_1.LogLevel.Error);
|
|
30
27
|
process.exit(2);
|
|
31
28
|
}
|
|
32
29
|
};
|
|
30
|
+
exports.startApp = startApp;
|
|
33
31
|
var loaders_2 = require("./loaders");
|
|
34
32
|
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 = 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');
|
|
8
|
+
exports.appPath = (0, path_1.join)(process.cwd(), './service/src/node/');
|
|
9
|
+
exports.bundlePath = (0, path_1.join)(exports.appPath, 'index');
|
|
10
|
+
exports.serviceJsonPath = (0, 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,17 +15,18 @@ 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 : os_1.cpus().length;
|
|
18
|
+
const workersFromUser = workers && Number.isInteger(workers) ? workers : (0, 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
|
+
const 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;
|
|
29
30
|
const defaultClients = {
|
|
30
31
|
options: {
|
|
31
32
|
messages: {
|
|
@@ -40,7 +41,7 @@ const defaultClients = {
|
|
|
40
41
|
},
|
|
41
42
|
},
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
+
const getService = () => {
|
|
44
45
|
var _a;
|
|
45
46
|
const { default: service } = require(exports.bundlePath);
|
|
46
47
|
const { config: { clients } } = service;
|
|
@@ -53,3 +54,4 @@ exports.getService = () => {
|
|
|
53
54
|
};
|
|
54
55
|
return service;
|
|
55
56
|
};
|
|
57
|
+
exports.getService = getService;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLogClient = void 0;
|
|
4
|
+
const diagnostics_nodejs_1 = require("@vtex/diagnostics-nodejs");
|
|
5
|
+
const telemetry_1 = require("../telemetry");
|
|
6
|
+
let logClient;
|
|
7
|
+
let isInitializing = false;
|
|
8
|
+
let initPromise = undefined;
|
|
9
|
+
async function getLogClient(account, workspace, appName) {
|
|
10
|
+
if (logClient) {
|
|
11
|
+
return logClient;
|
|
12
|
+
}
|
|
13
|
+
if (initPromise) {
|
|
14
|
+
return initPromise;
|
|
15
|
+
}
|
|
16
|
+
isInitializing = true;
|
|
17
|
+
initPromise = initializeClient(account, workspace, appName);
|
|
18
|
+
return initPromise;
|
|
19
|
+
}
|
|
20
|
+
exports.getLogClient = getLogClient;
|
|
21
|
+
async function initializeClient(account, workspace, appName) {
|
|
22
|
+
try {
|
|
23
|
+
const telemetryClient = await (0, telemetry_1.getTelemetryClient)();
|
|
24
|
+
const logsConfig = diagnostics_nodejs_1.Exporters.CreateLogsExporterConfig({
|
|
25
|
+
endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
26
|
+
path: process.env.OTEL_EXPORTER_OTLP_PATH || '/v1/logs',
|
|
27
|
+
protocol: 'http',
|
|
28
|
+
interval: 5,
|
|
29
|
+
timeoutSeconds: 5,
|
|
30
|
+
headers: { 'Content-Type': 'application/json' },
|
|
31
|
+
});
|
|
32
|
+
const logsExporter = diagnostics_nodejs_1.Exporters.CreateExporter(logsConfig, 'otlp');
|
|
33
|
+
await logsExporter.initialize();
|
|
34
|
+
const clientKey = `${account}-${workspace}-${appName}`;
|
|
35
|
+
logClient = await telemetryClient.newLogsClient({
|
|
36
|
+
exporter: logsExporter,
|
|
37
|
+
loggerName: `node-vtex-api-${clientKey}`,
|
|
38
|
+
});
|
|
39
|
+
return logClient;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error('Failed to initialize logs client:', error);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
isInitializing = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -7,23 +7,25 @@ const history = new caches_1.LRUCache({
|
|
|
7
7
|
max: 42,
|
|
8
8
|
});
|
|
9
9
|
exports.LOG_ONCE = 'logOnce';
|
|
10
|
-
|
|
11
|
-
exports.
|
|
10
|
+
const isLog = (message) => (message === null || message === void 0 ? void 0 : message.cmd) === exports.LOG_ONCE;
|
|
11
|
+
exports.isLog = isLog;
|
|
12
|
+
const log = (message, level) => {
|
|
12
13
|
const logger = console[level];
|
|
13
14
|
if (typeof logger === 'function') {
|
|
14
15
|
logger(message);
|
|
15
16
|
}
|
|
16
17
|
};
|
|
18
|
+
exports.log = log;
|
|
17
19
|
// Since we are now using clusters, if we simply console.log something,
|
|
18
20
|
// it may overwhelm the programmer's console with lots of repeated info.
|
|
19
21
|
// This function should be used when you want to warn about something
|
|
20
22
|
// only once
|
|
21
|
-
|
|
23
|
+
const logOnceToDevConsole = (message, level) => {
|
|
22
24
|
const strigified = JSON.stringify(message);
|
|
23
25
|
if (!history.has(strigified)) {
|
|
24
26
|
history.set(strigified, true);
|
|
25
27
|
if (cluster_1.isMaster) {
|
|
26
|
-
exports.log(message, level);
|
|
28
|
+
(0, exports.log)(message, level);
|
|
27
29
|
}
|
|
28
30
|
else if (cluster_1.isWorker && process.send) {
|
|
29
31
|
const logMessage = {
|
|
@@ -35,3 +37,4 @@ exports.logOnceToDevConsole = (message, level) => {
|
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
};
|
|
40
|
+
exports.logOnceToDevConsole = logOnceToDevConsole;
|
|
@@ -1,14 +1,20 @@
|
|
|
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("./console"), exports);
|
|
14
18
|
__exportStar(require("./logger"), exports);
|
|
19
|
+
__exportStar(require("./loggerTypes"), exports);
|
|
20
|
+
__exportStar(require("./client"), exports);
|