@dynatrace-sdk/client-query 1.10.1 → 1.11.0

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/cjs/index.js CHANGED
@@ -177,6 +177,8 @@ function serializeData(data) {
177
177
  function getMessagesFromErrorDetails(details) {
178
178
  const messages = [];
179
179
  Object.entries(details).forEach(([name, data]) => {
180
+ if (!data)
181
+ return;
180
182
  const serializedData = serializeData(data);
181
183
  switch (name) {
182
184
  case "missingScopes":
@@ -1392,10 +1394,10 @@ function isVerifyRequest(value) {
1392
1394
  if (Array.isArray(value)) {
1393
1395
  return false;
1394
1396
  }
1395
- const modelKeys = /* @__PURE__ */ new Set(["query", "timezone", "locale", "queryOptions"]);
1397
+ const modelKeys = /* @__PURE__ */ new Set(["query", "timezone", "locale", "queryOptions", "generateCanonicalQuery"]);
1396
1398
  const hasAdditionalProperties = false;
1397
1399
  const requiredKeys = ["query"];
1398
- const optionalKeys = ["timezone", "locale", "queryOptions"];
1400
+ const optionalKeys = ["timezone", "locale", "queryOptions", "generateCanonicalQuery"];
1399
1401
  const valKeys = new Set(Object.keys(value));
1400
1402
  const containsRequiredOrOptionalKeys = requiredKeys.length > 0 ? requiredKeys.every((reqKey) => valKeys.has(reqKey)) : optionalKeys.some((key) => valKeys.has(key)) || hasAdditionalProperties;
1401
1403
  const doesNotContainExtraKeys = [...valKeys].every((key) => modelKeys.has(key)) || hasAdditionalProperties;
@@ -1412,10 +1414,10 @@ function isJson18(value) {
1412
1414
  if (Array.isArray(value)) {
1413
1415
  return false;
1414
1416
  }
1415
- const modelKeys = /* @__PURE__ */ new Set(["query", "timezone", "locale", "queryOptions"]);
1417
+ const modelKeys = /* @__PURE__ */ new Set(["query", "timezone", "locale", "queryOptions", "generateCanonicalQuery"]);
1416
1418
  const hasAdditionalProperties = false;
1417
1419
  const requiredKeys = ["query"];
1418
- const optionalKeys = ["timezone", "locale", "queryOptions"];
1420
+ const optionalKeys = ["timezone", "locale", "queryOptions", "generateCanonicalQuery"];
1419
1421
  const valKeys = new Set(Object.keys(value));
1420
1422
  const containsRequiredOrOptionalKeys = requiredKeys.length > 0 ? requiredKeys.every((reqKey) => valKeys.has(reqKey)) : optionalKeys.some((key) => valKeys.has(key)) || hasAdditionalProperties;
1421
1423
  const doesNotContainExtraKeys = [...valKeys].every((key) => modelKeys.has(key)) || hasAdditionalProperties;
@@ -1423,21 +1425,23 @@ function isJson18(value) {
1423
1425
  return containsRequiredOrOptionalKeys && doesNotContainExtraKeys && allPropertiesMatchFormat;
1424
1426
  }
1425
1427
  function fromJson18($model) {
1426
- const { query, timezone, locale, queryOptions } = $model;
1428
+ const { query, timezone, locale, queryOptions, generateCanonicalQuery } = $model;
1427
1429
  return {
1428
1430
  query,
1429
1431
  timezone,
1430
1432
  locale,
1431
- queryOptions: queryOptions !== void 0 && queryOptions !== null ? fromJson(queryOptions) : void 0
1433
+ queryOptions: queryOptions !== void 0 && queryOptions !== null ? fromJson(queryOptions) : void 0,
1434
+ generateCanonicalQuery
1432
1435
  };
1433
1436
  }
1434
1437
  function toJson18($model) {
1435
- const { query, timezone, locale, queryOptions } = $model;
1438
+ const { query, timezone, locale, queryOptions, generateCanonicalQuery } = $model;
1436
1439
  return {
1437
1440
  query,
1438
1441
  timezone,
1439
1442
  locale,
1440
- queryOptions: queryOptions !== void 0 && queryOptions !== null ? toJson(queryOptions) : void 0
1443
+ queryOptions: queryOptions !== void 0 && queryOptions !== null ? toJson(queryOptions) : void 0,
1444
+ generateCanonicalQuery
1441
1445
  };
1442
1446
  }
1443
1447
 
@@ -1582,10 +1586,10 @@ function isVerifyResponse(value) {
1582
1586
  if (Array.isArray(value)) {
1583
1587
  return false;
1584
1588
  }
1585
- const modelKeys = /* @__PURE__ */ new Set(["valid", "notifications"]);
1589
+ const modelKeys = /* @__PURE__ */ new Set(["valid", "canonicalQuery", "notifications"]);
1586
1590
  const hasAdditionalProperties = false;
1587
1591
  const requiredKeys = ["valid"];
1588
- const optionalKeys = ["notifications"];
1592
+ const optionalKeys = ["canonicalQuery", "notifications"];
1589
1593
  const valKeys = new Set(Object.keys(value));
1590
1594
  const containsRequiredOrOptionalKeys = requiredKeys.length > 0 ? requiredKeys.every((reqKey) => valKeys.has(reqKey)) : optionalKeys.some((key) => valKeys.has(key)) || hasAdditionalProperties;
1591
1595
  const doesNotContainExtraKeys = [...valKeys].every((key) => modelKeys.has(key)) || hasAdditionalProperties;
@@ -1602,10 +1606,10 @@ function isJson20(value) {
1602
1606
  if (Array.isArray(value)) {
1603
1607
  return false;
1604
1608
  }
1605
- const modelKeys = /* @__PURE__ */ new Set(["valid", "notifications"]);
1609
+ const modelKeys = /* @__PURE__ */ new Set(["valid", "canonicalQuery", "notifications"]);
1606
1610
  const hasAdditionalProperties = false;
1607
1611
  const requiredKeys = ["valid"];
1608
- const optionalKeys = ["notifications"];
1612
+ const optionalKeys = ["canonicalQuery", "notifications"];
1609
1613
  const valKeys = new Set(Object.keys(value));
1610
1614
  const containsRequiredOrOptionalKeys = requiredKeys.length > 0 ? requiredKeys.every((reqKey) => valKeys.has(reqKey)) : optionalKeys.some((key) => valKeys.has(key)) || hasAdditionalProperties;
1611
1615
  const doesNotContainExtraKeys = [...valKeys].every((key) => modelKeys.has(key)) || hasAdditionalProperties;
@@ -1613,16 +1617,18 @@ function isJson20(value) {
1613
1617
  return containsRequiredOrOptionalKeys && doesNotContainExtraKeys && allPropertiesMatchFormat;
1614
1618
  }
1615
1619
  function fromJson20($model) {
1616
- const { valid, notifications } = $model;
1620
+ const { valid, canonicalQuery, notifications } = $model;
1617
1621
  return {
1618
1622
  valid,
1623
+ canonicalQuery,
1619
1624
  notifications: notifications !== void 0 && notifications !== null ? notifications?.map((innerValue) => fromJson19(innerValue)) : void 0
1620
1625
  };
1621
1626
  }
1622
1627
  function toJson20($model) {
1623
- const { valid, notifications } = $model;
1628
+ const { valid, canonicalQuery, notifications } = $model;
1624
1629
  return {
1625
1630
  valid,
1631
+ canonicalQuery,
1626
1632
  notifications: notifications !== void 0 && notifications !== null ? notifications?.map((innerValue) => toJson19(innerValue)) : void 0
1627
1633
  };
1628
1634
  }
@@ -1639,9 +1645,6 @@ var QueryAssistanceClient = class {
1639
1645
  throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
1640
1646
  }
1641
1647
  const encodedBody = toJson18(config.body);
1642
- const headerParameters = {
1643
- ...config.authorization !== void 0 && { Authorization: String(config.authorization) }
1644
- };
1645
1648
  try {
1646
1649
  const response = await this.httpClient.send({
1647
1650
  url: `/platform/storage/query/v1/query:verify`,
@@ -1650,8 +1653,7 @@ var QueryAssistanceClient = class {
1650
1653
  body: encodedBody,
1651
1654
  headers: {
1652
1655
  "Content-Type": "application/json",
1653
- Accept: "application/json",
1654
- ...headerParameters
1656
+ Accept: "application/json"
1655
1657
  },
1656
1658
  abortSignal: config.abortSignal,
1657
1659
  statusValidator: (status) => {
@@ -1684,7 +1686,7 @@ var QueryAssistanceClient = class {
1684
1686
  try {
1685
1687
  const errorBody = fromJson16(responseValue);
1686
1688
  throw new ErrorEnvelopeError(
1687
- "400",
1689
+ `400`,
1688
1690
  response,
1689
1691
  errorBody,
1690
1692
  getErrorMessage(errorBody, "The supplied request is wrong."),
@@ -1708,7 +1710,7 @@ var QueryAssistanceClient = class {
1708
1710
  try {
1709
1711
  const errorBody = fromJson16(responseValue);
1710
1712
  throw new ErrorEnvelopeError(
1711
- "500",
1713
+ `500`,
1712
1714
  response,
1713
1715
  errorBody,
1714
1716
  getErrorMessage(errorBody, "An internal server error has occurred."),
@@ -1745,9 +1747,6 @@ var QueryAssistanceClient = class {
1745
1747
  throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
1746
1748
  }
1747
1749
  const encodedBody = toJson17(config.body);
1748
- const headerParameters = {
1749
- ...config.authorization !== void 0 && { Authorization: String(config.authorization) }
1750
- };
1751
1750
  try {
1752
1751
  const response = await this.httpClient.send({
1753
1752
  url: `/platform/storage/query/v1/query:parse`,
@@ -1756,8 +1755,7 @@ var QueryAssistanceClient = class {
1756
1755
  body: encodedBody,
1757
1756
  headers: {
1758
1757
  "Content-Type": "application/json",
1759
- Accept: "application/json",
1760
- ...headerParameters
1758
+ Accept: "application/json"
1761
1759
  },
1762
1760
  abortSignal: config.abortSignal,
1763
1761
  statusValidator: (status) => {
@@ -1790,7 +1788,7 @@ var QueryAssistanceClient = class {
1790
1788
  try {
1791
1789
  const errorBody = fromJson16(responseValue);
1792
1790
  throw new ErrorEnvelopeError(
1793
- "400",
1791
+ `400`,
1794
1792
  response,
1795
1793
  errorBody,
1796
1794
  getErrorMessage(
@@ -1817,7 +1815,7 @@ var QueryAssistanceClient = class {
1817
1815
  try {
1818
1816
  const errorBody = fromJson16(responseValue);
1819
1817
  throw new ErrorEnvelopeError(
1820
- "500",
1818
+ `500`,
1821
1819
  response,
1822
1820
  errorBody,
1823
1821
  getErrorMessage(errorBody, "An internal server error has occurred."),
@@ -1854,9 +1852,6 @@ var QueryAssistanceClient = class {
1854
1852
  throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
1855
1853
  }
1856
1854
  const encodedBody = toJson2(config.body);
1857
- const headerParameters = {
1858
- ...config.authorization !== void 0 && { Authorization: String(config.authorization) }
1859
- };
1860
1855
  try {
1861
1856
  const response = await this.httpClient.send({
1862
1857
  url: `/platform/storage/query/v1/query:autocomplete`,
@@ -1865,8 +1860,7 @@ var QueryAssistanceClient = class {
1865
1860
  body: encodedBody,
1866
1861
  headers: {
1867
1862
  "Content-Type": "application/json",
1868
- Accept: "application/json",
1869
- ...headerParameters
1863
+ Accept: "application/json"
1870
1864
  },
1871
1865
  abortSignal: config.abortSignal,
1872
1866
  statusValidator: (status) => {
@@ -1899,7 +1893,7 @@ var QueryAssistanceClient = class {
1899
1893
  try {
1900
1894
  const errorBody = fromJson16(responseValue);
1901
1895
  throw new ErrorEnvelopeError(
1902
- "400",
1896
+ `400`,
1903
1897
  response,
1904
1898
  errorBody,
1905
1899
  getErrorMessage(
@@ -1926,7 +1920,7 @@ var QueryAssistanceClient = class {
1926
1920
  try {
1927
1921
  const errorBody = fromJson16(responseValue);
1928
1922
  throw new ErrorEnvelopeError(
1929
- "500",
1923
+ `500`,
1930
1924
  response,
1931
1925
  errorBody,
1932
1926
  getErrorMessage(errorBody, "An internal server error has occurred."),
@@ -3342,7 +3336,7 @@ var QueryExecutionClient = class {
3342
3336
  try {
3343
3337
  const errorBody = fromJson16(responseValue);
3344
3338
  throw new ErrorEnvelopeError(
3345
- "400",
3339
+ `400`,
3346
3340
  response,
3347
3341
  errorBody,
3348
3342
  getErrorMessage(
@@ -3378,7 +3372,7 @@ var QueryExecutionClient = class {
3378
3372
  try {
3379
3373
  const errorBody = fromJson16(responseValue);
3380
3374
  throw new ErrorEnvelopeError(
3381
- "500",
3375
+ `500`,
3382
3376
  response,
3383
3377
  errorBody,
3384
3378
  getErrorMessage(errorBody, "An internal server error has occurred."),
@@ -3416,9 +3410,6 @@ var QueryExecutionClient = class {
3416
3410
  }
3417
3411
  const encodedBody = toJson21(config.body);
3418
3412
  const query = toQueryString({ enrich: config.enrich });
3419
- const headerParameters = {
3420
- ...config.authorization !== void 0 && { Authorization: String(config.authorization) }
3421
- };
3422
3413
  try {
3423
3414
  const response = await this.httpClient.send({
3424
3415
  url: `/platform/storage/query/v1/query:execute${query}`,
@@ -3427,8 +3418,7 @@ var QueryExecutionClient = class {
3427
3418
  body: encodedBody,
3428
3419
  headers: {
3429
3420
  "Content-Type": "application/json",
3430
- Accept: "application/json",
3431
- ...headerParameters
3421
+ Accept: "application/json"
3432
3422
  },
3433
3423
  abortSignal: config.abortSignal,
3434
3424
  statusValidator: (status) => {
@@ -3488,7 +3478,7 @@ var QueryExecutionClient = class {
3488
3478
  try {
3489
3479
  const errorBody = fromJson16(responseValue);
3490
3480
  throw new ErrorEnvelopeError(
3491
- "400",
3481
+ `400`,
3492
3482
  response,
3493
3483
  errorBody,
3494
3484
  getErrorMessage(
@@ -3515,7 +3505,7 @@ var QueryExecutionClient = class {
3515
3505
  try {
3516
3506
  const errorBody = fromJson16(responseValue);
3517
3507
  throw new ErrorEnvelopeError(
3518
- "403",
3508
+ `403`,
3519
3509
  response,
3520
3510
  errorBody,
3521
3511
  getErrorMessage(errorBody, "Insufficient permissions."),
@@ -3539,7 +3529,7 @@ var QueryExecutionClient = class {
3539
3529
  try {
3540
3530
  const errorBody = fromJson16(responseValue);
3541
3531
  throw new ErrorEnvelopeError(
3542
- "429",
3532
+ `429`,
3543
3533
  response,
3544
3534
  errorBody,
3545
3535
  getErrorMessage(errorBody, "Too many requests."),
@@ -3563,7 +3553,7 @@ var QueryExecutionClient = class {
3563
3553
  try {
3564
3554
  const errorBody = fromJson16(responseValue);
3565
3555
  throw new ErrorEnvelopeError(
3566
- "500",
3556
+ `500`,
3567
3557
  response,
3568
3558
  errorBody,
3569
3559
  getErrorMessage(errorBody, "An internal server error has occurred."),
@@ -3587,7 +3577,7 @@ var QueryExecutionClient = class {
3587
3577
  try {
3588
3578
  const errorBody = fromJson16(responseValue);
3589
3579
  throw new ErrorEnvelopeError(
3590
- "503",
3580
+ `503`,
3591
3581
  response,
3592
3582
  errorBody,
3593
3583
  getErrorMessage(errorBody, "Service is unavailable."),
@@ -3611,13 +3601,19 @@ var QueryExecutionClient = class {
3611
3601
  const responseValue = await response.body("json");
3612
3602
  try {
3613
3603
  const errorBody = fromJson16(responseValue);
3614
- throw new ErrorEnvelopeError("4XX", response, errorBody, getErrorMessage(errorBody, "Client error."), e);
3604
+ throw new ErrorEnvelopeError(
3605
+ `${response.status}`,
3606
+ response,
3607
+ errorBody,
3608
+ getErrorMessage(errorBody, "Client error."),
3609
+ e
3610
+ );
3615
3611
  } catch (err) {
3616
3612
  if (err instanceof ErrorEnvelopeError) {
3617
3613
  throw err;
3618
3614
  }
3619
3615
  throw new InvalidResponseError(
3620
- `QueryExecutionClient.query:execute:4XX`,
3616
+ `QueryExecutionClient.query:execute:${response.status}`,
3621
3617
  err,
3622
3618
  responseValue,
3623
3619
  "ErrorEnvelope",
@@ -3628,13 +3624,19 @@ var QueryExecutionClient = class {
3628
3624
  const responseValue = await response.body("json");
3629
3625
  try {
3630
3626
  const errorBody = fromJson16(responseValue);
3631
- throw new ErrorEnvelopeError("5XX", response, errorBody, getErrorMessage(errorBody, "Server error."), e);
3627
+ throw new ErrorEnvelopeError(
3628
+ `${response.status}`,
3629
+ response,
3630
+ errorBody,
3631
+ getErrorMessage(errorBody, "Server error."),
3632
+ e
3633
+ );
3632
3634
  } catch (err) {
3633
3635
  if (err instanceof ErrorEnvelopeError) {
3634
3636
  throw err;
3635
3637
  }
3636
3638
  throw new InvalidResponseError(
3637
- `QueryExecutionClient.query:execute:5XX`,
3639
+ `QueryExecutionClient.query:execute:${response.status}`,
3638
3640
  err,
3639
3641
  responseValue,
3640
3642
  "ErrorEnvelope",
@@ -3719,7 +3721,7 @@ var QueryExecutionClient = class {
3719
3721
  try {
3720
3722
  const errorBody = fromJson16(responseValue);
3721
3723
  throw new ErrorEnvelopeError(
3722
- "400",
3724
+ `400`,
3723
3725
  response,
3724
3726
  errorBody,
3725
3727
  getErrorMessage(
@@ -3755,7 +3757,7 @@ var QueryExecutionClient = class {
3755
3757
  try {
3756
3758
  const errorBody = fromJson16(responseValue);
3757
3759
  throw new ErrorEnvelopeError(
3758
- "500",
3760
+ `500`,
3759
3761
  response,
3760
3762
  errorBody,
3761
3763
  getErrorMessage(errorBody, "An internal server error has occurred."),