@mablhq/mabl-cli 1.45.1 → 1.45.8

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.
@@ -3,12 +3,13 @@ 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.RequestInterceptor = exports.headerStringToProtocol = exports.headerStringToHeaders = void 0;
6
+ exports.RequestInterceptor = exports.headerStringToProtocol = exports.headerStringToHeaders = exports.MAX_SERIALIZED_BODY_SIZE_BYTES = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const loggingProvider_1 = require("../providers/logging/loggingProvider");
9
9
  const uuid_1 = require("uuid");
10
10
  const httpUtil_1 = require("./httpUtil");
11
- const MAX_SERIALIZED_BODY_SIZE_BYTES = 1024 * 1024;
11
+ const pureUtil_1 = require("../util/pureUtil");
12
+ exports.MAX_SERIALIZED_BODY_SIZE_BYTES = 1024 * 1024;
12
13
  const HEADER_EXTRACT_REGEXP = /^(?<rawKey>[^:]+)(:)(?<value>.*)$/;
13
14
  function headerStringToHeaders(rawHeader) {
14
15
  const headers = {};
@@ -52,20 +53,31 @@ function handleRawResponseBody(body) {
52
53
  body = body !== null && body !== void 0 ? body : '';
53
54
  switch (typeof body) {
54
55
  case 'number':
56
+ return { body: body.toString(), responseSize: 8 };
55
57
  case 'boolean':
56
- return body.toString();
58
+ return { body: body.toString(), responseSize: 4 };
57
59
  case 'string':
58
- return body.substring(0, MAX_SERIALIZED_BODY_SIZE_BYTES);
60
+ return {
61
+ body: body.substring(0, exports.MAX_SERIALIZED_BODY_SIZE_BYTES),
62
+ responseSize: body.length,
63
+ };
59
64
  case 'object':
60
65
  const serializedBody = JSON.stringify(body);
61
- if (serializedBody.length <= MAX_SERIALIZED_BODY_SIZE_BYTES) {
62
- return body;
66
+ if (serializedBody.length <= exports.MAX_SERIALIZED_BODY_SIZE_BYTES) {
67
+ return { body, responseSize: serializedBody.length };
63
68
  }
64
- return serializedBody.substring(0, MAX_SERIALIZED_BODY_SIZE_BYTES);
69
+ return {
70
+ body: serializedBody.substring(0, exports.MAX_SERIALIZED_BODY_SIZE_BYTES),
71
+ responseSize: serializedBody.length,
72
+ };
65
73
  default:
66
74
  throw new Error(`Unhandled request intercept body type: [${typeof body}]`);
67
75
  }
68
76
  }
77
+ function getContentLength(headers) {
78
+ const contentLengthAsString = (0, pureUtil_1.getCaseInsensitiveProperty)(headers, 'content-length');
79
+ return contentLengthAsString ? Number(contentLengthAsString) : undefined;
80
+ }
69
81
  class RequestInterceptor {
70
82
  constructor() {
71
83
  this.interceptedRequests = [];
@@ -132,11 +144,14 @@ class RequestInterceptor {
132
144
  ? headerStringToProtocol(request._header)
133
145
  : '<Unknown protocol>';
134
146
  }
147
+ const { body, responseSize } = handleRawResponseBody(response.data);
148
+ const contentLength = getContentLength(response.headers);
135
149
  chainEntry.response = {
136
150
  headers: headerRecordToHeaderMultiMap(response.headers),
137
151
  status: response.status,
138
152
  response_received_time: responseReceivedTime,
139
- body: handleRawResponseBody(response.data),
153
+ response_size: contentLength !== null && contentLength !== void 0 ? contentLength : responseSize,
154
+ body,
140
155
  };
141
156
  }
142
157
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mablhq/mabl-cli",
3
- "version": "1.45.1",
3
+ "version": "1.45.8",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "The official mabl command line interface tool",
6
6
  "main": "index.js",
package/util/pureUtil.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getCaseInsensitiveProperty = exports.extractKeyCountsFromArgs = exports.getCliName = exports.getCliVersion = exports.stringify = exports.isWholeNumber = exports.isString = exports.isNullish = exports.isDefined = void 0;
26
+ exports.getCaseInsensitiveProperty = exports.extractKeyCountsFromArgs = exports.getCliName = exports.getCliVersion = exports.stringifyIfPresent = exports.stringify = exports.isWholeNumber = exports.isString = exports.isNullish = exports.isDefined = void 0;
27
27
  const fs = __importStar(require("fs"));
28
28
  const path = __importStar(require("path"));
29
29
  const possibleCliPackagePaths = Object.freeze([
@@ -75,6 +75,13 @@ function stringify(value) {
75
75
  return value.toString();
76
76
  }
77
77
  exports.stringify = stringify;
78
+ function stringifyIfPresent(value) {
79
+ if (isNullish(value)) {
80
+ return;
81
+ }
82
+ return stringify(value);
83
+ }
84
+ exports.stringifyIfPresent = stringifyIfPresent;
78
85
  function getCliVersion() {
79
86
  return getCliPackage().version;
80
87
  }