@dynatrace-sdk/client-query 1.21.1 → 1.21.2

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.
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "dynagen": {
3
- "version": "0.19.3",
3
+ "version": "0.19.9",
4
4
  "template": {
5
5
  "name": "@dynatrace-sdk/template-typescript-client",
6
- "version": "0.34.0"
6
+ "version": "0.34.4"
7
7
  },
8
8
  "featureFlags": {
9
9
  "typeguards": true
package/esm/index.js CHANGED
@@ -20,12 +20,6 @@ import {
20
20
  isHttpClientAbortError,
21
21
  isHttpClientResponseError
22
22
  } from "@dynatrace-sdk/http-client";
23
- import {
24
- apiGatewayErrorsHandler,
25
- getErrorMessage,
26
- transformRequest,
27
- transformResponse
28
- } from "@dynatrace-sdk/shared-client-utils";
29
23
  import {
30
24
  ApiClientError,
31
25
  ClientRequestError as ClientRequestError2,
@@ -33,6 +27,15 @@ import {
33
27
  isInvalidResponseError
34
28
  } from "@dynatrace-sdk/shared-errors";
35
29
 
30
+ // packages/client/query/src/lib/error-envelopes/api-gateway-errors-handler.ts
31
+ import { ApiGatewayError } from "@dynatrace-sdk/shared-errors";
32
+ async function apiGatewayErrorsHandler(response) {
33
+ if (response.headers?.["dynatrace-response-source"] === "API Gateway") {
34
+ const responseBody = await response.body("json");
35
+ throw new ApiGatewayError(response, responseBody);
36
+ }
37
+ }
38
+
36
39
  // packages/client/query/src/lib/error-envelopes/error-envelope-error.ts
37
40
  import { ClientRequestError } from "@dynatrace-sdk/shared-errors";
38
41
  var ErrorEnvelopeError = class extends ClientRequestError {
@@ -42,6 +45,198 @@ function isErrorEnvelopeError(e) {
42
45
  return e?.isApiClientError === true && e?.isClientRequestError === true && e?.isErrorEnvelopeError === true && e instanceof Error;
43
46
  }
44
47
 
48
+ // packages/client/query/src/lib/error-envelopes/get-error-message.ts
49
+ function serializeData(data) {
50
+ try {
51
+ return JSON.stringify(data);
52
+ } catch (e) {
53
+ return String(data);
54
+ }
55
+ }
56
+ function getMessagesFromErrorDetails(details) {
57
+ const messages = [];
58
+ Object.entries(details).forEach(([name, data]) => {
59
+ if (!data)
60
+ return;
61
+ const serializedData = serializeData(data);
62
+ switch (name) {
63
+ case "missingScopes":
64
+ messages.push(`Missing scopes: ${serializedData}`);
65
+ break;
66
+ default:
67
+ messages.push(`${name}: ${serializedData}`);
68
+ }
69
+ }, []);
70
+ return messages;
71
+ }
72
+ function getErrorMessage(errorBody, defaultMessage) {
73
+ const error = errorBody;
74
+ const msg = error?.error?.message || defaultMessage;
75
+ const details = error?.error?.details || {};
76
+ return [msg, ...getMessagesFromErrorDetails(details)].join(". ");
77
+ }
78
+
79
+ // packages/client/query/src/lib/utils/transformations.ts
80
+ var defaultRuleConfig = {
81
+ force: false,
82
+ datetime: false
83
+ };
84
+ function mergeKeys(key1, key2) {
85
+ if (!key1)
86
+ return key2;
87
+ if (!key2)
88
+ return key1;
89
+ return `${key1}.${key2}`;
90
+ }
91
+ function matchKey(key, rules, cache) {
92
+ if (cache.has(key)) {
93
+ return cache.get(key);
94
+ }
95
+ for (const rule of rules) {
96
+ const pattern = Array.isArray(rule) ? rule[0] : rule;
97
+ const config = Array.isArray(rule) ? rule[1] : defaultRuleConfig;
98
+ if (key === pattern) {
99
+ const result = [pattern, config];
100
+ cache.set(key, result);
101
+ return result;
102
+ }
103
+ let i = 0;
104
+ let j = 0;
105
+ const keyLen = key.length;
106
+ const patternLen = pattern.length;
107
+ let isMatch = true;
108
+ while (i < keyLen && j < patternLen) {
109
+ let keyPartEnd = key.indexOf(".", i);
110
+ let patternPartEnd = pattern.indexOf(".", j);
111
+ if (keyPartEnd === -1)
112
+ keyPartEnd = keyLen;
113
+ if (patternPartEnd === -1)
114
+ patternPartEnd = patternLen;
115
+ const keyPart = key.slice(i, keyPartEnd);
116
+ const patternPart = pattern.slice(j, patternPartEnd);
117
+ if (patternPart !== "*" && patternPart !== "**" && keyPart !== patternPart) {
118
+ isMatch = false;
119
+ break;
120
+ }
121
+ i = keyPartEnd + 1;
122
+ j = patternPartEnd + 1;
123
+ }
124
+ if (isMatch) {
125
+ if (j < patternLen) {
126
+ const remaining = pattern.slice(j);
127
+ if (remaining !== "**" && remaining !== "*") {
128
+ isMatch = false;
129
+ }
130
+ }
131
+ if (i < keyLen && pattern.slice(j - 1) !== "**") {
132
+ isMatch = false;
133
+ }
134
+ }
135
+ if (isMatch) {
136
+ const result = [pattern, config];
137
+ cache.set(key, result);
138
+ return result;
139
+ }
140
+ }
141
+ cache.set(key, null);
142
+ return null;
143
+ }
144
+ var potentialMatchForRoot = (pattern, key) => pattern.startsWith(key) || pattern.startsWith("*") || pattern.startsWith("**");
145
+ var potentialMatch = (pattern, key) => pattern.startsWith(key) || pattern.includes("*") || pattern.includes("**");
146
+ function partialMatch(key, keyPatterns) {
147
+ const keyPatternsLen = keyPatterns.length;
148
+ if (!key.includes(".")) {
149
+ for (let i = 0; i < keyPatternsLen; i++) {
150
+ const pattern = keyPatterns[i];
151
+ if (potentialMatchForRoot(pattern, key))
152
+ return true;
153
+ }
154
+ return false;
155
+ }
156
+ let dotIndex = -1;
157
+ let currentKeyEnd = 0;
158
+ while ((dotIndex = key.indexOf(".", currentKeyEnd)) !== -1) {
159
+ const currentKey = key.slice(0, dotIndex);
160
+ const isRoot = !currentKey.includes(".");
161
+ for (let i = 0; i < keyPatternsLen; i++) {
162
+ const pattern = keyPatterns[i];
163
+ if (isRoot) {
164
+ if (potentialMatchForRoot(pattern, currentKey))
165
+ return true;
166
+ } else if (potentialMatch(pattern, currentKey))
167
+ return true;
168
+ }
169
+ currentKeyEnd = dotIndex + 1;
170
+ }
171
+ for (let i = 0; i < keyPatternsLen; i++) {
172
+ const pattern = keyPatterns[i];
173
+ if (potentialMatch(pattern, key))
174
+ return true;
175
+ }
176
+ return false;
177
+ }
178
+ var dateTimePattern = /^(\d{4}-\d{2}-\d{2})(T\d{2}:\d{2}:\d{2}(?:\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/i;
179
+ function isDateLike(value) {
180
+ if (typeof value === "string") {
181
+ return dateTimePattern.test(value);
182
+ }
183
+ return false;
184
+ }
185
+ function transformValue(value, rules, direction) {
186
+ const { force, datetime } = rules;
187
+ if (direction === "to") {
188
+ return force || isDateLike(value) ? new Date(value) : value;
189
+ }
190
+ if (value instanceof Date) {
191
+ const iso = value.toISOString();
192
+ return datetime ? iso : iso.split("T")[0];
193
+ }
194
+ return value;
195
+ }
196
+ function walk(obj, direction, rules, rulesCache, keyPatterns, currentKey = "") {
197
+ if (rules.length <= 0) {
198
+ return obj;
199
+ }
200
+ if (!partialMatch(currentKey, keyPatterns)) {
201
+ return obj;
202
+ }
203
+ if (Array.isArray(obj)) {
204
+ const match = matchKey(currentKey, rules, rulesCache);
205
+ obj.forEach((item, idx) => {
206
+ if (typeof item === "object" && item !== null) {
207
+ walk(item, direction, rules, rulesCache, keyPatterns, currentKey);
208
+ } else if (match) {
209
+ obj[idx] = transformValue(obj[idx], match[1], direction);
210
+ }
211
+ });
212
+ }
213
+ if (typeof obj === "object" && obj !== null && !Array.isArray(obj)) {
214
+ for (const key of Object.keys(obj)) {
215
+ const mergedKey = mergeKeys(currentKey, key);
216
+ const match = matchKey(mergedKey, rules, rulesCache);
217
+ if (match) {
218
+ obj[key] = transformValue(obj[key], match[1], direction);
219
+ }
220
+ walk(obj[key], direction, rules, rulesCache, keyPatterns, mergedKey);
221
+ }
222
+ }
223
+ return obj;
224
+ }
225
+ function flattenKeyPatterns(keyPatterns) {
226
+ return keyPatterns.map((k) => Array.isArray(k) ? k[0] : k);
227
+ }
228
+ function transform(direction, object, rules) {
229
+ const flatKeyPatterns = flattenKeyPatterns(rules);
230
+ const rulesCache = /* @__PURE__ */ new Map();
231
+ return walk(object, direction, rules, rulesCache, flatKeyPatterns);
232
+ }
233
+ function transformRequest(object, rules) {
234
+ return transform("from", object, rules);
235
+ }
236
+ function transformResponse(object, rules) {
237
+ return transform("to", object, rules);
238
+ }
239
+
45
240
  // packages/client/query/src/lib/apis/query-assistance-api.ts
46
241
  var QueryAssistanceClient = class {
47
242
  httpClient;
@@ -753,15 +948,6 @@ import {
753
948
  isHttpClientAbortError as isHttpClientAbortError2,
754
949
  isHttpClientResponseError as isHttpClientResponseError2
755
950
  } from "@dynatrace-sdk/http-client";
756
- import {
757
- Encoding,
758
- apiGatewayErrorsHandler as apiGatewayErrorsHandler2,
759
- getErrorMessage as getErrorMessage2,
760
- mimeTypeToEncoding,
761
- toQueryString,
762
- transformRequest as transformRequest2,
763
- transformResponse as transformResponse2
764
- } from "@dynatrace-sdk/shared-client-utils";
765
951
  import {
766
952
  ApiClientError as ApiClientError2,
767
953
  ClientRequestError as ClientRequestError3,
@@ -779,6 +965,55 @@ function isInsufficientPermission(e) {
779
965
  return e?.isApiClientError === true && e?.isClientRequestError === true && e?.isErrorEnvelopeError === true && e?.isInsufficientPermission === true && e instanceof Error;
780
966
  }
781
967
 
968
+ // packages/client/query/src/lib/utils/encoding.ts
969
+ function mimeTypeToEncoding(mimeType, defaultEncoding) {
970
+ const shortMimeType = mimeType.split(";")[0];
971
+ switch (shortMimeType) {
972
+ case "application/json":
973
+ case "application/cloudevent+json":
974
+ case "application/cloudevent-batch+json":
975
+ return "json" /* Json */;
976
+ case "text/plain":
977
+ return "text" /* Text */;
978
+ case "application/octet-stream":
979
+ return "binary" /* Binary */;
980
+ case "multipart/form-data":
981
+ return "form-data" /* FormData */;
982
+ default:
983
+ if (defaultEncoding)
984
+ return defaultEncoding;
985
+ else
986
+ throw new Error(`${shortMimeType} mime type is not yet supported`);
987
+ }
988
+ }
989
+
990
+ // packages/client/query/src/lib/utils/url-helpers.ts
991
+ var encodeQueryParam = (key, value) => {
992
+ const encodedKey = encodeURIComponent(key);
993
+ return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : String(value))}`;
994
+ };
995
+ var addExplodedArrayQueryParam = (query, key) => {
996
+ const arrayValue = query[key];
997
+ return arrayValue.map((value) => encodeQueryParam(key, value)).join("&");
998
+ };
999
+ var addNonExplodedArrayQueryParams = (query, key) => {
1000
+ const encodedKey = encodeURIComponent(key);
1001
+ const encodedParamsList = query[key].map((value) => encodeURIComponent(typeof value === "number" ? value : String(value))).join(",");
1002
+ return `${encodedKey}=${encodedParamsList}`;
1003
+ };
1004
+ var addQueryParam = (query, key) => encodeQueryParam(key, query[key]);
1005
+ var arrayQueryParams = (query, key, explode) => {
1006
+ return explode ? addExplodedArrayQueryParam(query, key) : addNonExplodedArrayQueryParams(query, key);
1007
+ };
1008
+ var toQueryString = (rawQuery, flags = {}) => {
1009
+ const query = rawQuery || {};
1010
+ const keys = Object.keys(query).filter((key) => typeof query[key] !== "undefined");
1011
+ const queryString = keys.map(
1012
+ (key) => Array.isArray(query[key]) ? arrayQueryParams(query, key, flags.explode?.hasOwnProperty(key) ? flags.explode[key] : true) : addQueryParam(query, key)
1013
+ ).join("&");
1014
+ return queryString ? `?${queryString}` : "";
1015
+ };
1016
+
782
1017
  // packages/client/query/src/lib/apis/query-execution-api.ts
783
1018
  var QueryExecutionClient = class {
784
1019
  httpClient;
@@ -873,7 +1108,7 @@ var QueryExecutionClient = class {
873
1108
  });
874
1109
  const responseValue = await response.body("json");
875
1110
  try {
876
- return this.shouldTransformDates ? transformResponse2(responseValue, [
1111
+ return this.shouldTransformDates ? transformResponse(responseValue, [
877
1112
  ["result.records.*.start", { datetime: true }],
878
1113
  ["result.records.*.end", { datetime: true }],
879
1114
  ["result.records.**.start", { datetime: true }],
@@ -901,17 +1136,17 @@ var QueryExecutionClient = class {
901
1136
  throw new ApiClientError2("UnexpectedError", "Unexpected error", e);
902
1137
  }
903
1138
  const response = e.response;
904
- await apiGatewayErrorsHandler2(response);
1139
+ await apiGatewayErrorsHandler(response);
905
1140
  switch (response.status) {
906
1141
  case 400: {
907
1142
  const responseValue = await response.body("json");
908
1143
  try {
909
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1144
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
910
1145
  throw new ErrorEnvelopeError(
911
1146
  `400`,
912
1147
  response,
913
1148
  errorBody,
914
- getErrorMessage2(
1149
+ getErrorMessage(
915
1150
  errorBody,
916
1151
  "The supplied request is wrong. Either the query itself or other parameters are wrong."
917
1152
  ),
@@ -933,24 +1168,24 @@ var QueryExecutionClient = class {
933
1168
  }
934
1169
  case 410: {
935
1170
  const contentType = response.headers["content-type"];
936
- const encoding = mimeTypeToEncoding(contentType, Encoding.Text);
1171
+ const encoding = mimeTypeToEncoding(contentType, "text" /* Text */);
937
1172
  const responseValue = await response.body(encoding);
938
1173
  throw new ClientRequestError3(
939
1174
  `410`,
940
1175
  response,
941
1176
  responseValue,
942
- getErrorMessage2(responseValue, `The query for the given request-token is not available anymore.`)
1177
+ getErrorMessage(responseValue, `The query for the given request-token is not available anymore.`)
943
1178
  );
944
1179
  }
945
1180
  case 500: {
946
1181
  const responseValue = await response.body("json");
947
1182
  try {
948
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1183
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
949
1184
  throw new ErrorEnvelopeError(
950
1185
  `500`,
951
1186
  response,
952
1187
  errorBody,
953
- getErrorMessage2(errorBody, "An internal server error has occurred."),
1188
+ getErrorMessage(errorBody, "An internal server error has occurred."),
954
1189
  e
955
1190
  );
956
1191
  } catch (err) {
@@ -974,7 +1209,7 @@ var QueryExecutionClient = class {
974
1209
  `${response.status}`,
975
1210
  response,
976
1211
  responseValue,
977
- getErrorMessage2(
1212
+ getErrorMessage(
978
1213
  responseValue,
979
1214
  `Unexpected api response: code=${response.status} body="${responseValue}"`
980
1215
  ),
@@ -1059,7 +1294,7 @@ var QueryExecutionClient = class {
1059
1294
  if (!config) {
1060
1295
  throw new ApiClientError2("API client error", "API client call is missing mandatory config parameter");
1061
1296
  }
1062
- const encodedBody = this.shouldTransformDates ? transformRequest2(config.body, []) : config.body;
1297
+ const encodedBody = this.shouldTransformDates ? transformRequest(config.body, []) : config.body;
1063
1298
  const query = toQueryString({ enrich: config.enrich });
1064
1299
  const headerParameters = {
1065
1300
  ...config.dtClientContext !== void 0 && { "dt-client-context": String(config.dtClientContext) },
@@ -1087,7 +1322,7 @@ var QueryExecutionClient = class {
1087
1322
  case 200: {
1088
1323
  const responseValue = await response.body("json");
1089
1324
  try {
1090
- return this.shouldTransformDates ? transformResponse2(responseValue, [
1325
+ return this.shouldTransformDates ? transformResponse(responseValue, [
1091
1326
  ["result.records.*.start", { datetime: true }],
1092
1327
  ["result.records.*.end", { datetime: true }],
1093
1328
  ["result.records.**.start", { datetime: true }],
@@ -1111,7 +1346,7 @@ var QueryExecutionClient = class {
1111
1346
  case 202: {
1112
1347
  const responseValue = await response.body("json");
1113
1348
  try {
1114
- return this.shouldTransformDates ? transformResponse2(responseValue, [
1349
+ return this.shouldTransformDates ? transformResponse(responseValue, [
1115
1350
  ["result.records.*.start", { datetime: true }],
1116
1351
  ["result.records.*.end", { datetime: true }],
1117
1352
  ["result.records.**.start", { datetime: true }],
@@ -1139,7 +1374,7 @@ var QueryExecutionClient = class {
1139
1374
  `${response.status}`,
1140
1375
  response,
1141
1376
  responseValue,
1142
- getErrorMessage2(
1377
+ getErrorMessage(
1143
1378
  responseValue,
1144
1379
  `Unexpected api response: code=${response.status} body="${responseValue}"`
1145
1380
  )
@@ -1168,17 +1403,17 @@ var QueryExecutionClient = class {
1168
1403
  throw new ApiClientError2("UnexpectedError", "Unexpected error", e);
1169
1404
  }
1170
1405
  const response = e.response;
1171
- await apiGatewayErrorsHandler2(response);
1406
+ await apiGatewayErrorsHandler(response);
1172
1407
  switch (response.status) {
1173
1408
  case 400: {
1174
1409
  const responseValue = await response.body("json");
1175
1410
  try {
1176
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1411
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
1177
1412
  throw new ErrorEnvelopeError(
1178
1413
  `400`,
1179
1414
  response,
1180
1415
  errorBody,
1181
- getErrorMessage2(
1416
+ getErrorMessage(
1182
1417
  errorBody,
1183
1418
  "The supplied request is wrong. Either the query itself or other parameters are wrong."
1184
1419
  ),
@@ -1201,12 +1436,12 @@ var QueryExecutionClient = class {
1201
1436
  case 403: {
1202
1437
  const responseValue = await response.body("json");
1203
1438
  try {
1204
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1439
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
1205
1440
  throw new InsufficientPermission(
1206
1441
  `403`,
1207
1442
  response,
1208
1443
  errorBody,
1209
- getErrorMessage2(errorBody, "Insufficient permissions."),
1444
+ getErrorMessage(errorBody, "Insufficient permissions."),
1210
1445
  e
1211
1446
  );
1212
1447
  } catch (err) {
@@ -1226,12 +1461,12 @@ var QueryExecutionClient = class {
1226
1461
  case 429: {
1227
1462
  const responseValue = await response.body("json");
1228
1463
  try {
1229
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1464
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
1230
1465
  throw new ErrorEnvelopeError(
1231
1466
  `429`,
1232
1467
  response,
1233
1468
  errorBody,
1234
- getErrorMessage2(errorBody, "Too many requests."),
1469
+ getErrorMessage(errorBody, "Too many requests."),
1235
1470
  e
1236
1471
  );
1237
1472
  } catch (err) {
@@ -1251,12 +1486,12 @@ var QueryExecutionClient = class {
1251
1486
  case 500: {
1252
1487
  const responseValue = await response.body("json");
1253
1488
  try {
1254
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1489
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
1255
1490
  throw new ErrorEnvelopeError(
1256
1491
  `500`,
1257
1492
  response,
1258
1493
  errorBody,
1259
- getErrorMessage2(errorBody, "An internal server error has occurred."),
1494
+ getErrorMessage(errorBody, "An internal server error has occurred."),
1260
1495
  e
1261
1496
  );
1262
1497
  } catch (err) {
@@ -1276,12 +1511,12 @@ var QueryExecutionClient = class {
1276
1511
  case 503: {
1277
1512
  const responseValue = await response.body("json");
1278
1513
  try {
1279
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1514
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
1280
1515
  throw new ErrorEnvelopeError(
1281
1516
  `503`,
1282
1517
  response,
1283
1518
  errorBody,
1284
- getErrorMessage2(errorBody, "Service is unavailable."),
1519
+ getErrorMessage(errorBody, "Service is unavailable."),
1285
1520
  e
1286
1521
  );
1287
1522
  } catch (err) {
@@ -1302,12 +1537,12 @@ var QueryExecutionClient = class {
1302
1537
  if (response.status >= 400 && response.status <= 499) {
1303
1538
  const responseValue = await response.body("json");
1304
1539
  try {
1305
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1540
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
1306
1541
  throw new ErrorEnvelopeError(
1307
1542
  `${response.status}`,
1308
1543
  response,
1309
1544
  errorBody,
1310
- getErrorMessage2(errorBody, "Client error."),
1545
+ getErrorMessage(errorBody, "Client error."),
1311
1546
  e
1312
1547
  );
1313
1548
  } catch (err) {
@@ -1326,12 +1561,12 @@ var QueryExecutionClient = class {
1326
1561
  } else if (response.status >= 500 && response.status <= 599) {
1327
1562
  const responseValue = await response.body("json");
1328
1563
  try {
1329
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1564
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
1330
1565
  throw new ErrorEnvelopeError(
1331
1566
  `${response.status}`,
1332
1567
  response,
1333
1568
  errorBody,
1334
- getErrorMessage2(errorBody, "Server error."),
1569
+ getErrorMessage(errorBody, "Server error."),
1335
1570
  e
1336
1571
  );
1337
1572
  } catch (err) {
@@ -1354,7 +1589,7 @@ var QueryExecutionClient = class {
1354
1589
  `${response.status}`,
1355
1590
  response,
1356
1591
  responseValue,
1357
- getErrorMessage2(
1592
+ getErrorMessage(
1358
1593
  responseValue,
1359
1594
  `Unexpected api response: code=${response.status} body="${responseValue}"`
1360
1595
  )
@@ -1458,7 +1693,7 @@ var QueryExecutionClient = class {
1458
1693
  case 200: {
1459
1694
  const responseValue = await response.body("json");
1460
1695
  try {
1461
- return this.shouldTransformDates ? transformResponse2(responseValue, [
1696
+ return this.shouldTransformDates ? transformResponse(responseValue, [
1462
1697
  ["result.records.*.start", { datetime: true }],
1463
1698
  ["result.records.*.end", { datetime: true }],
1464
1699
  ["result.records.**.start", { datetime: true }],
@@ -1489,7 +1724,7 @@ var QueryExecutionClient = class {
1489
1724
  `${response.status}`,
1490
1725
  response,
1491
1726
  responseValue,
1492
- getErrorMessage2(
1727
+ getErrorMessage(
1493
1728
  responseValue,
1494
1729
  `Unexpected api response: code=${response.status} body="${responseValue}"`
1495
1730
  )
@@ -1518,17 +1753,17 @@ var QueryExecutionClient = class {
1518
1753
  throw new ApiClientError2("UnexpectedError", "Unexpected error", e);
1519
1754
  }
1520
1755
  const response = e.response;
1521
- await apiGatewayErrorsHandler2(response);
1756
+ await apiGatewayErrorsHandler(response);
1522
1757
  switch (response.status) {
1523
1758
  case 400: {
1524
1759
  const responseValue = await response.body("json");
1525
1760
  try {
1526
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1761
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
1527
1762
  throw new ErrorEnvelopeError(
1528
1763
  `400`,
1529
1764
  response,
1530
1765
  errorBody,
1531
- getErrorMessage2(
1766
+ getErrorMessage(
1532
1767
  errorBody,
1533
1768
  "The supplied request is wrong. Either the query itself or other parameters are wrong."
1534
1769
  ),
@@ -1550,24 +1785,24 @@ var QueryExecutionClient = class {
1550
1785
  }
1551
1786
  case 410: {
1552
1787
  const contentType = response.headers["content-type"];
1553
- const encoding = mimeTypeToEncoding(contentType, Encoding.Text);
1788
+ const encoding = mimeTypeToEncoding(contentType, "text" /* Text */);
1554
1789
  const responseValue = await response.body(encoding);
1555
1790
  throw new ClientRequestError3(
1556
1791
  `410`,
1557
1792
  response,
1558
1793
  responseValue,
1559
- getErrorMessage2(responseValue, `The query for the given request-token is not available anymore.`)
1794
+ getErrorMessage(responseValue, `The query for the given request-token is not available anymore.`)
1560
1795
  );
1561
1796
  }
1562
1797
  case 500: {
1563
1798
  const responseValue = await response.body("json");
1564
1799
  try {
1565
- const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
1800
+ const errorBody = this.shouldTransformDates ? transformResponse(responseValue, []) : responseValue;
1566
1801
  throw new ErrorEnvelopeError(
1567
1802
  `500`,
1568
1803
  response,
1569
1804
  errorBody,
1570
- getErrorMessage2(errorBody, "An internal server error has occurred."),
1805
+ getErrorMessage(errorBody, "An internal server error has occurred."),
1571
1806
  e
1572
1807
  );
1573
1808
  } catch (err) {
@@ -1591,7 +1826,7 @@ var QueryExecutionClient = class {
1591
1826
  `${response.status}`,
1592
1827
  response,
1593
1828
  responseValue,
1594
- getErrorMessage2(
1829
+ getErrorMessage(
1595
1830
  responseValue,
1596
1831
  `Unexpected api response: code=${response.status} body="${responseValue}"`
1597
1832
  ),
@@ -1621,7 +1856,7 @@ var queryExecutionClient = /* @__PURE__ */ new QueryExecutionClient(defaultHttpC
1621
1856
  // packages/client/query/src/lib/error-envelopes/index.ts
1622
1857
  import {
1623
1858
  ApiClientError as ApiClientError3,
1624
- ApiGatewayError,
1859
+ ApiGatewayError as ApiGatewayError2,
1625
1860
  ClientRequestError as ClientRequestError4,
1626
1861
  InvalidResponseError as InvalidResponseError3,
1627
1862
  isApiClientError,
@@ -1734,7 +1969,7 @@ var TokenType = /* @__PURE__ */ ((TokenType2) => {
1734
1969
  })(TokenType || {});
1735
1970
  export {
1736
1971
  ApiClientError3 as ApiClientError,
1737
- ApiGatewayError,
1972
+ ApiGatewayError2 as ApiGatewayError,
1738
1973
  ClientRequestError4 as ClientRequestError,
1739
1974
  DQLNodeNodeType,
1740
1975
  ErrorEnvelopeError,
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@dynatrace-sdk/client-query",
3
- "version": "1.21.1",
3
+ "version": "1.21.2",
4
4
  "description": "Exposes an API to fetch records stored in Grail.",
5
5
  "license": "Apache-2.0",
6
6
  "dependencies": {
7
- "@dynatrace-sdk/http-client": "^1.3.0",
8
- "@dynatrace-sdk/shared-client-utils": "^1.0.1",
9
- "@dynatrace-sdk/shared-errors": "^1.0.0"
7
+ "@dynatrace-sdk/http-client": "^1.3.1",
8
+ "@dynatrace-sdk/shared-errors": "^1.0.2"
10
9
  },
11
10
  "main": "./cjs/index.js",
12
11
  "module": "./esm/index.js",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Configuration for the API client.
2
+ * Configuration for generated TypeScript SDK clients
3
3
  * @param {boolean} transformDates - Flag to control date transformations, enabled by default.
4
4
  */
5
5
  export interface ApiClientOptions {
@@ -1,11 +1,11 @@
1
1
  import { AbortSignal, HttpClient } from '@dynatrace-sdk/http-client';
2
- import { ApiClientOptions } from '@dynatrace-sdk/shared-client-utils';
3
2
  import { AutocompleteRequest } from '../models/autocomplete-request';
4
3
  import { AutocompleteResponse } from '../models/autocomplete-response';
5
4
  import { DQLNode } from '../models/dql-node';
6
5
  import { ParseRequest } from '../models/parse-request';
7
6
  import { VerifyRequest } from '../models/verify-request';
8
7
  import { VerifyResponse } from '../models/verify-response';
8
+ import { ApiClientOptions } from './api-client-options';
9
9
  /**
10
10
  * Supporting operations for the Query. Also known as the Language services.
11
11
  */
@@ -1,8 +1,8 @@
1
1
  import { AbortSignal, HttpClient } from '@dynatrace-sdk/http-client';
2
- import { ApiClientOptions } from '@dynatrace-sdk/shared-client-utils';
3
2
  import { ExecuteRequest } from '../models/execute-request';
4
3
  import { QueryPollResponse } from '../models/query-poll-response';
5
4
  import { QueryStartResponse } from '../models/query-start-response';
5
+ import { ApiClientOptions } from './api-client-options';
6
6
  /**
7
7
  * Operations related to the Query execution.
8
8
  */
@@ -0,0 +1,2 @@
1
+ import { HttpClientResponse } from '@dynatrace-sdk/http-client';
2
+ export declare function apiGatewayErrorsHandler(response: HttpClientResponse): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function getErrorMessage(errorBody: unknown, defaultMessage: string): string;