@vtex/api 6.45.21-beta.0 → 6.45.21-beta.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/CHANGELOG.md CHANGED
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [6.45.21-beta.1] - 2023-09-07
11
+
10
12
  ## [6.45.21-beta.0] - 2023-09-04
11
13
 
12
14
  ## [6.45.21-beta] - 2023-09-04
@@ -1780,11 +1782,12 @@ instead
1780
1782
  - `HttpClient` now adds `'Accept-Encoding': 'gzip'` header by default.
1781
1783
 
1782
1784
 
1783
- [Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.45.21-beta.0...HEAD
1785
+ [Unreleased]: https://github.com/vtex/node-vtex-api/compare/v6.45.21-beta.1...HEAD
1784
1786
  [6.45.15]: https://github.com/vtex/node-vtex-api/compare/v6.45.14...v6.45.15
1785
1787
  [6.45.14]: https://github.com/vtex/node-vtex-api/compare/v6.45.13...v6.45.14
1786
1788
  [6.45.13]: https://github.com/vtex/node-vtex-api/compare/v6.45.12...v6.45.13
1787
1789
 
1790
+ [6.45.21-beta.1]: https://github.com/vtex/node-vtex-api/compare/v6.45.21-beta.0...v6.45.21-beta.1
1788
1791
  [6.45.21-beta.0]: https://github.com/vtex/node-vtex-api/compare/v6.45.21-beta...v6.45.21-beta.0
1789
1792
  [6.45.21-beta]: https://github.com/vtex/node-vtex-api/compare/v6.45.20...v6.45.21-beta
1790
1793
  [6.45.20]: https://github.com/vtex/node-vtex-api/compare/v6.45.20-beta...v6.45.20
@@ -20,6 +20,7 @@ exports.addTracingMiddleware = (tracer) => {
20
20
  const start = process.hrtime();
21
21
  concurrentRequests.inc(1);
22
22
  const rootSpan = tracer.extract(opentracing_1.FORMAT_HTTP_HEADERS, ctx.request.headers);
23
+ ctx.tracing = { tracer, currentSpan: undefined };
23
24
  if (!shouldTrace(ctx, rootSpan)) {
24
25
  await next();
25
26
  concurrentRequests.dec(1);
@@ -86,8 +87,8 @@ exports.addTracingMiddleware = (tracer) => {
86
87
  };
87
88
  exports.nameSpanOperationMiddleware = (operationType, operationName) => {
88
89
  return function nameSpanOperation(ctx, next) {
89
- var _a;
90
- (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan.setOperationName(`${operationType}:${operationName}`);
90
+ var _a, _b;
91
+ (_b = (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan) === null || _b === void 0 ? void 0 : _b.setOperationName(`${operationType}:${operationName}`);
91
92
  return next();
92
93
  };
93
94
  };
@@ -101,7 +102,7 @@ exports.traceUserLandRemainingPipelineMiddleware = () => {
101
102
  userLandTracer.lockFallbackSpan();
102
103
  const startTime = process.hrtime();
103
104
  try {
104
- span.log({ event: "user-middlewares-start" /* USER_MIDDLEWARES_START */ });
105
+ span === null || span === void 0 ? void 0 : span.log({ event: "user-middlewares-start" /* USER_MIDDLEWARES_START */ });
105
106
  await next();
106
107
  }
107
108
  catch (err) {
@@ -109,7 +110,7 @@ exports.traceUserLandRemainingPipelineMiddleware = () => {
109
110
  throw err;
110
111
  }
111
112
  finally {
112
- span.log({
113
+ span === null || span === void 0 ? void 0 : span.log({
113
114
  event: "user-middlewares-finish" /* USER_MIDDLEWARES_FINISH */,
114
115
  ["user-middlewares-duration" /* USER_MIDDLEWARES_DURATION */]: utils_2.hrToMillis(process.hrtime(startTime)),
115
116
  });
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.whoAmIHandler = ({ events, routes, }) => (ctx) => {
4
- var _a;
5
- (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan.setOperationName('builtin:whoami');
4
+ var _a, _b;
5
+ (_b = (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan) === null || _b === void 0 ? void 0 : _b.setOperationName('builtin:whoami');
6
6
  ctx.status = 200;
7
7
  ctx.body = {
8
8
  events,
@@ -11,8 +11,8 @@ exports.whoAmIHandler = ({ events, routes, }) => (ctx) => {
11
11
  ctx.set('Cache-Control', 'public, max-age=86400'); // cache for 24 hours
12
12
  };
13
13
  exports.healthcheckHandler = ({ events, routes, }) => (ctx) => {
14
- var _a;
15
- (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan.setOperationName('builtin:healthcheck');
14
+ var _a, _b;
15
+ (_b = (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan) === null || _b === void 0 ? void 0 : _b.setOperationName('builtin:healthcheck');
16
16
  ctx.status = 200;
17
17
  ctx.body = {
18
18
  events,
@@ -20,8 +20,8 @@ exports.healthcheckHandler = ({ events, routes, }) => (ctx) => {
20
20
  };
21
21
  };
22
22
  exports.metricsLoggerHandler = (ctx) => {
23
- var _a;
24
- (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan.setOperationName('builtin:metrics-logger');
23
+ var _a, _b;
24
+ (_b = (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan) === null || _b === void 0 ? void 0 : _b.setOperationName('builtin:metrics-logger');
25
25
  ctx.status = 200;
26
26
  ctx.body = ctx.metricsLogger.getSummaries();
27
27
  };
@@ -10,10 +10,10 @@ const STATUS_TRACK = 'statusTrack';
10
10
  exports.isStatusTrack = (message) => message === STATUS_TRACK;
11
11
  exports.isStatusTrackBroadcast = (message) => message === BROADCAST_STATUS_TRACK;
12
12
  exports.statusTrackHandler = async (ctx) => {
13
- var _a, _b;
14
- (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan.setOperationName('builtin:status-track');
13
+ var _a, _b, _c;
14
+ (_b = (_a = ctx.tracing) === null || _a === void 0 ? void 0 : _a.currentSpan) === null || _b === void 0 ? void 0 : _b.setOperationName('builtin:status-track');
15
15
  if (!constants_1.LINKED) {
16
- (_b = process.send) === null || _b === void 0 ? void 0 : _b.call(process, BROADCAST_STATUS_TRACK);
16
+ (_c = process.send) === null || _c === void 0 ? void 0 : _c.call(process, BROADCAST_STATUS_TRACK);
17
17
  }
18
18
  ctx.body = [];
19
19
  return;
@@ -21,7 +21,7 @@ declare type ServerTiming = Record<string, string>;
21
21
  export declare type Maybe<T> = T | null | undefined;
22
22
  export interface TracingContext {
23
23
  tracer: Tracer;
24
- currentSpan: Span;
24
+ currentSpan: Span | undefined;
25
25
  }
26
26
  export interface Context<T extends IOClients> {
27
27
  clients: T;
@@ -29,7 +29,7 @@ exports.prepareHandlerCtx = (header, tracingContext) => {
29
29
  segmentToken: header[constants_1.SEGMENT_HEADER],
30
30
  sessionToken: header[constants_1.SESSION_HEADER],
31
31
  tenant: header[constants_1.TENANT_HEADER] ? tenant_1.parseTenantHeaderValue(header[constants_1.TENANT_HEADER]) : undefined,
32
- tracer: new UserLandTracer_1.UserLandTracer(tracingContext.tracer, tracingContext.currentSpan),
32
+ tracer: new UserLandTracer_1.UserLandTracer(tracingContext === null || tracingContext === void 0 ? void 0 : tracingContext.tracer, tracingContext === null || tracingContext === void 0 ? void 0 : tracingContext.currentSpan),
33
33
  userAgent: process.env.VTEX_APP_ID || '',
34
34
  workspace: header[constants_1.WORKSPACE_HEADER],
35
35
  };
@@ -1,10 +1,10 @@
1
1
  import { Span, SpanContext, SpanOptions, Tracer } from 'opentracing';
2
2
  export interface IUserLandTracer {
3
- traceId: string;
3
+ traceId?: string;
4
4
  isTraceSampled: boolean;
5
5
  startSpan: Tracer['startSpan'];
6
6
  inject: Tracer['inject'];
7
- fallbackSpanContext: () => SpanContext;
7
+ fallbackSpanContext: () => SpanContext | undefined;
8
8
  }
9
9
  export declare const createTracingContextFromCarrier: (newSpanName: string, carrier: Record<string, any>) => {
10
10
  span: Span;
@@ -15,13 +15,13 @@ export declare class UserLandTracer implements IUserLandTracer {
15
15
  private fallbackSpan;
16
16
  private fallbackSpanLock;
17
17
  private _isSampled;
18
- private _traceId;
19
- constructor(tracer: Tracer, fallbackSpan: Span);
20
- get traceId(): string;
18
+ private _traceId?;
19
+ constructor(tracer: Tracer, fallbackSpan?: Span);
20
+ get traceId(): string | undefined;
21
21
  get isTraceSampled(): boolean;
22
22
  lockFallbackSpan(): void;
23
- setFallbackSpan(newSpan: Span): void;
23
+ setFallbackSpan(newSpan?: Span): void;
24
24
  startSpan(name: string, options?: SpanOptions): Span;
25
25
  inject(spanContext: SpanContext | Span, format: string, carrier: any): void;
26
- fallbackSpanContext(): SpanContext;
26
+ fallbackSpanContext(): SpanContext | undefined;
27
27
  }
@@ -49,7 +49,8 @@ class UserLandTracer {
49
49
  return this.tracer.inject(spanContext, format, carrier);
50
50
  }
51
51
  fallbackSpanContext() {
52
- return this.fallbackSpan.context();
52
+ var _a;
53
+ return (_a = this.fallbackSpan) === null || _a === void 0 ? void 0 : _a.context();
53
54
  }
54
55
  }
55
56
  exports.UserLandTracer = UserLandTracer;
@@ -26,6 +26,6 @@ export declare class ErrorReport extends ErrorReportBase {
26
26
  * instance on the provided Span. If a logger is provided and the
27
27
  * span is part of a **sampled** trace, then the error will be logged.
28
28
  */
29
- injectOnSpan(span: Span, logger?: IOContext['logger']): this;
29
+ injectOnSpan(span?: Span, logger?: IOContext['logger']): this;
30
30
  private shouldLogToSplunk;
31
31
  }
@@ -35,7 +35,7 @@ class ErrorReport extends node_error_report_1.ErrorReportBase {
35
35
  */
36
36
  injectOnSpan(span, logger) {
37
37
  var _a;
38
- span.setTag(__1.TracingTags.ERROR, 'true');
38
+ span === null || span === void 0 ? void 0 : span.setTag(__1.TracingTags.ERROR, 'true');
39
39
  const indexedLogs = {
40
40
  ["error.kind" /* ERROR_KIND */]: this.kind,
41
41
  ["error.id" /* ERROR_ID */]: this.metadata.errorId,
@@ -47,7 +47,7 @@ class ErrorReport extends node_error_report_1.ErrorReportBase {
47
47
  indexedLogs["error.server.request_id" /* ERROR_SERVER_REQUEST_ID */] = this.parsedInfo.response.data.requestId;
48
48
  }
49
49
  const serializableError = this.toObject();
50
- span.log({ event: 'error', ...indexedLogs, error: serializableError });
50
+ span === null || span === void 0 ? void 0 : span.log({ event: 'error', ...indexedLogs, error: serializableError });
51
51
  if (logger && this.shouldLogToSplunk(span)) {
52
52
  logger.error(serializableError);
53
53
  this.markErrorAsReported();
@@ -1,9 +1,9 @@
1
1
  import { Span } from 'opentracing';
2
2
  export interface TraceInfo {
3
- traceId: string;
3
+ traceId?: string;
4
4
  isSampled: boolean;
5
5
  }
6
- export declare function getTraceInfo(span: Span): TraceInfo;
6
+ export declare function getTraceInfo(span?: Span): TraceInfo;
7
7
  /**
8
8
  * Do a shallow copy of a headers object and redacts sensitive information.
9
9
  *
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const node_error_report_1 = require("@vtex/node-error-report");
4
4
  function getTraceInfo(span) {
5
5
  var _a, _b, _c;
6
- const spanContext = span.context();
6
+ const spanContext = span === null || span === void 0 ? void 0 : span.context();
7
7
  return {
8
- isSampled: (_c = (_b = (_a = spanContext).isSampled) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : false,
9
- traceId: spanContext.toTraceId(),
8
+ isSampled: (_c = (_b = (_a = spanContext) === null || _a === void 0 ? void 0 : _a.isSampled) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : false,
9
+ traceId: spanContext === null || spanContext === void 0 ? void 0 : spanContext.toTraceId(),
10
10
  };
11
11
  }
12
12
  exports.getTraceInfo = getTraceInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "6.45.21-beta.0",
3
+ "version": "6.45.21-beta.1",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",