@dynatrace-sdk/client-query 1.3.0 → 1.4.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 +21 -0
- package/README.md +1 -1
- package/cjs/index.js +101 -19
- package/docs/DOCS.md +251 -1356
- package/dynatrace-metadata.json +3 -3
- package/esm/index.js +101 -19
- package/package.json +2 -2
- package/types/packages/client/query/src/lib/error-envelopes/get-error-message.d.ts +1 -0
- package/types/packages/client/query/src/lib/error-envelopes/index.d.ts +1 -0
- package/types/packages/client/query/src/lib/models/execute-request.d.ts +4 -0
- package/types/packages/client/query/src/lib/models/execute-request.transformation.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
@dynatrace-sdk/client-query
|
|
4
4
|
|
|
5
|
+
## 1.4.1
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- Update error messages
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
- @dynatrace-sdk/http-client@1.0.5
|
|
13
|
+
|
|
14
|
+
## 1.4.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- Add `max-result-bytes` query parameter to DPS Query API
|
|
19
|
+
|
|
20
|
+
## 1.3.1
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Update documentation
|
|
25
|
+
|
|
5
26
|
## 1.3.0
|
|
6
27
|
|
|
7
28
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @dynatrace-sdk/client-query
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@dynatrace-sdk/client-query/v/1.4.1)
|
|
4
4
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
5
5
|
|
|
6
6
|
Exposes an API to fetch records stored in Grail
|
package/cjs/index.js
CHANGED
|
@@ -79,6 +79,7 @@ __export(src_exports, {
|
|
|
79
79
|
isApiClientError: () => isApiClientError,
|
|
80
80
|
isClientRequestError: () => isClientRequestError,
|
|
81
81
|
isErrorEnvelopeError: () => isErrorEnvelopeError,
|
|
82
|
+
isInvalidResponseError: () => isInvalidResponseError,
|
|
82
83
|
queryAssistanceClient: () => queryAssistanceClient,
|
|
83
84
|
queryExecutionClient: () => queryExecutionClient
|
|
84
85
|
});
|
|
@@ -177,6 +178,27 @@ function getOptionalErrorRef(body) {
|
|
|
177
178
|
return {};
|
|
178
179
|
}
|
|
179
180
|
|
|
181
|
+
// packages/client/query/src/lib/error-envelopes/get-error-message.ts
|
|
182
|
+
function getMessagesFromErrorDetails(details) {
|
|
183
|
+
const messages = [];
|
|
184
|
+
Object.entries(details).forEach(([name, data]) => {
|
|
185
|
+
switch (name) {
|
|
186
|
+
case "missingScopes":
|
|
187
|
+
messages.push(`Missing scopes: ${data}`);
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
messages.push(`${name}: ${data}`);
|
|
191
|
+
}
|
|
192
|
+
}, []);
|
|
193
|
+
return messages;
|
|
194
|
+
}
|
|
195
|
+
function getErrorMessage(errorBody, defaultMessage) {
|
|
196
|
+
const error = errorBody;
|
|
197
|
+
const msg = error?.error?.message || defaultMessage;
|
|
198
|
+
const details = error?.error?.details || {};
|
|
199
|
+
return [msg, ...getMessagesFromErrorDetails(details)].join(". ");
|
|
200
|
+
}
|
|
201
|
+
|
|
180
202
|
// packages/client/query/src/lib/error-envelopes/invalid-response-error.ts
|
|
181
203
|
var InvalidResponseError = class extends ApiClientError {
|
|
182
204
|
responseBody;
|
|
@@ -192,6 +214,9 @@ var InvalidResponseError = class extends ApiClientError {
|
|
|
192
214
|
this.expectedType = expectedType;
|
|
193
215
|
}
|
|
194
216
|
};
|
|
217
|
+
function isInvalidResponseError(e) {
|
|
218
|
+
return e instanceof InvalidResponseError;
|
|
219
|
+
}
|
|
195
220
|
|
|
196
221
|
// packages/client/query/src/lib/models/autocomplete-request.transformation.ts
|
|
197
222
|
var autocomplete_request_transformation_exports = {};
|
|
@@ -1520,7 +1545,12 @@ var QueryAssistanceClient = class {
|
|
|
1520
1545
|
const responseValue = await response.body("json");
|
|
1521
1546
|
try {
|
|
1522
1547
|
const errorBody = fromJson15(responseValue);
|
|
1523
|
-
throw new ErrorEnvelopeError(
|
|
1548
|
+
throw new ErrorEnvelopeError(
|
|
1549
|
+
"400",
|
|
1550
|
+
response,
|
|
1551
|
+
errorBody,
|
|
1552
|
+
getErrorMessage(errorBody, "The supplied request is wrong.")
|
|
1553
|
+
);
|
|
1524
1554
|
} catch (err) {
|
|
1525
1555
|
if (err instanceof ErrorEnvelopeError) {
|
|
1526
1556
|
throw err;
|
|
@@ -1538,7 +1568,12 @@ var QueryAssistanceClient = class {
|
|
|
1538
1568
|
const responseValue = await response.body("json");
|
|
1539
1569
|
try {
|
|
1540
1570
|
const errorBody = fromJson15(responseValue);
|
|
1541
|
-
throw new ErrorEnvelopeError(
|
|
1571
|
+
throw new ErrorEnvelopeError(
|
|
1572
|
+
"500",
|
|
1573
|
+
response,
|
|
1574
|
+
errorBody,
|
|
1575
|
+
getErrorMessage(errorBody, "An internal server error has occurred.")
|
|
1576
|
+
);
|
|
1542
1577
|
} catch (err) {
|
|
1543
1578
|
if (err instanceof ErrorEnvelopeError) {
|
|
1544
1579
|
throw err;
|
|
@@ -1572,7 +1607,7 @@ var QueryAssistanceClient = class {
|
|
|
1572
1607
|
`${response.status}`,
|
|
1573
1608
|
response,
|
|
1574
1609
|
responseValue,
|
|
1575
|
-
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1610
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
1576
1611
|
);
|
|
1577
1612
|
}
|
|
1578
1613
|
}
|
|
@@ -1612,7 +1647,10 @@ var QueryAssistanceClient = class {
|
|
|
1612
1647
|
"400",
|
|
1613
1648
|
response,
|
|
1614
1649
|
errorBody,
|
|
1615
|
-
|
|
1650
|
+
getErrorMessage(
|
|
1651
|
+
errorBody,
|
|
1652
|
+
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1653
|
+
)
|
|
1616
1654
|
);
|
|
1617
1655
|
} catch (err) {
|
|
1618
1656
|
if (err instanceof ErrorEnvelopeError) {
|
|
@@ -1631,7 +1669,12 @@ var QueryAssistanceClient = class {
|
|
|
1631
1669
|
const responseValue = await response.body("json");
|
|
1632
1670
|
try {
|
|
1633
1671
|
const errorBody = fromJson15(responseValue);
|
|
1634
|
-
throw new ErrorEnvelopeError(
|
|
1672
|
+
throw new ErrorEnvelopeError(
|
|
1673
|
+
"500",
|
|
1674
|
+
response,
|
|
1675
|
+
errorBody,
|
|
1676
|
+
getErrorMessage(errorBody, "An internal server error has occurred.")
|
|
1677
|
+
);
|
|
1635
1678
|
} catch (err) {
|
|
1636
1679
|
if (err instanceof ErrorEnvelopeError) {
|
|
1637
1680
|
throw err;
|
|
@@ -1665,7 +1708,7 @@ var QueryAssistanceClient = class {
|
|
|
1665
1708
|
`${response.status}`,
|
|
1666
1709
|
response,
|
|
1667
1710
|
responseValue,
|
|
1668
|
-
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1711
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
1669
1712
|
);
|
|
1670
1713
|
}
|
|
1671
1714
|
}
|
|
@@ -1705,7 +1748,10 @@ var QueryAssistanceClient = class {
|
|
|
1705
1748
|
"400",
|
|
1706
1749
|
response,
|
|
1707
1750
|
errorBody,
|
|
1708
|
-
|
|
1751
|
+
getErrorMessage(
|
|
1752
|
+
errorBody,
|
|
1753
|
+
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1754
|
+
)
|
|
1709
1755
|
);
|
|
1710
1756
|
} catch (err) {
|
|
1711
1757
|
if (err instanceof ErrorEnvelopeError) {
|
|
@@ -1724,7 +1770,12 @@ var QueryAssistanceClient = class {
|
|
|
1724
1770
|
const responseValue = await response.body("json");
|
|
1725
1771
|
try {
|
|
1726
1772
|
const errorBody = fromJson15(responseValue);
|
|
1727
|
-
throw new ErrorEnvelopeError(
|
|
1773
|
+
throw new ErrorEnvelopeError(
|
|
1774
|
+
"500",
|
|
1775
|
+
response,
|
|
1776
|
+
errorBody,
|
|
1777
|
+
getErrorMessage(errorBody, "An internal server error has occurred.")
|
|
1778
|
+
);
|
|
1728
1779
|
} catch (err) {
|
|
1729
1780
|
if (err instanceof ErrorEnvelopeError) {
|
|
1730
1781
|
throw err;
|
|
@@ -1758,7 +1809,7 @@ var QueryAssistanceClient = class {
|
|
|
1758
1809
|
`${response.status}`,
|
|
1759
1810
|
response,
|
|
1760
1811
|
responseValue,
|
|
1761
|
-
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1812
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
1762
1813
|
);
|
|
1763
1814
|
}
|
|
1764
1815
|
}
|
|
@@ -1794,6 +1845,7 @@ function isExecuteRequest(value) {
|
|
|
1794
1845
|
"timezone",
|
|
1795
1846
|
"locale",
|
|
1796
1847
|
"maxResultRecords",
|
|
1848
|
+
"maxResultBytes",
|
|
1797
1849
|
"fetchTimeoutSeconds",
|
|
1798
1850
|
"requestTimeoutMilliseconds",
|
|
1799
1851
|
"enablePreview",
|
|
@@ -1808,6 +1860,7 @@ function isExecuteRequest(value) {
|
|
|
1808
1860
|
"timezone",
|
|
1809
1861
|
"locale",
|
|
1810
1862
|
"maxResultRecords",
|
|
1863
|
+
"maxResultBytes",
|
|
1811
1864
|
"fetchTimeoutSeconds",
|
|
1812
1865
|
"requestTimeoutMilliseconds",
|
|
1813
1866
|
"enablePreview",
|
|
@@ -1836,6 +1889,7 @@ function isJson20(value) {
|
|
|
1836
1889
|
"timezone",
|
|
1837
1890
|
"locale",
|
|
1838
1891
|
"maxResultRecords",
|
|
1892
|
+
"maxResultBytes",
|
|
1839
1893
|
"fetchTimeoutSeconds",
|
|
1840
1894
|
"requestTimeoutMilliseconds",
|
|
1841
1895
|
"enablePreview",
|
|
@@ -1850,6 +1904,7 @@ function isJson20(value) {
|
|
|
1850
1904
|
"timezone",
|
|
1851
1905
|
"locale",
|
|
1852
1906
|
"maxResultRecords",
|
|
1907
|
+
"maxResultBytes",
|
|
1853
1908
|
"fetchTimeoutSeconds",
|
|
1854
1909
|
"requestTimeoutMilliseconds",
|
|
1855
1910
|
"enablePreview",
|
|
@@ -1869,6 +1924,7 @@ function fromJson20($model) {
|
|
|
1869
1924
|
timezone,
|
|
1870
1925
|
locale,
|
|
1871
1926
|
maxResultRecords,
|
|
1927
|
+
maxResultBytes,
|
|
1872
1928
|
fetchTimeoutSeconds,
|
|
1873
1929
|
requestTimeoutMilliseconds,
|
|
1874
1930
|
enablePreview,
|
|
@@ -1882,6 +1938,7 @@ function fromJson20($model) {
|
|
|
1882
1938
|
timezone,
|
|
1883
1939
|
locale,
|
|
1884
1940
|
maxResultRecords,
|
|
1941
|
+
maxResultBytes,
|
|
1885
1942
|
fetchTimeoutSeconds,
|
|
1886
1943
|
requestTimeoutMilliseconds,
|
|
1887
1944
|
enablePreview,
|
|
@@ -1897,6 +1954,7 @@ function toJson20($model) {
|
|
|
1897
1954
|
timezone,
|
|
1898
1955
|
locale,
|
|
1899
1956
|
maxResultRecords,
|
|
1957
|
+
maxResultBytes,
|
|
1900
1958
|
fetchTimeoutSeconds,
|
|
1901
1959
|
requestTimeoutMilliseconds,
|
|
1902
1960
|
enablePreview,
|
|
@@ -1910,6 +1968,7 @@ function toJson20($model) {
|
|
|
1910
1968
|
timezone,
|
|
1911
1969
|
locale,
|
|
1912
1970
|
maxResultRecords,
|
|
1971
|
+
maxResultBytes,
|
|
1913
1972
|
fetchTimeoutSeconds,
|
|
1914
1973
|
requestTimeoutMilliseconds,
|
|
1915
1974
|
enablePreview,
|
|
@@ -3031,14 +3090,19 @@ var QueryExecutionClient = class {
|
|
|
3031
3090
|
`410`,
|
|
3032
3091
|
response,
|
|
3033
3092
|
responseValue,
|
|
3034
|
-
`The query for the given request-token is not available anymore.`
|
|
3093
|
+
getErrorMessage(responseValue, `The query for the given request-token is not available anymore.`)
|
|
3035
3094
|
);
|
|
3036
3095
|
}
|
|
3037
3096
|
case 500: {
|
|
3038
3097
|
const responseValue = await response.body("json");
|
|
3039
3098
|
try {
|
|
3040
3099
|
const errorBody = fromJson15(responseValue);
|
|
3041
|
-
throw new ErrorEnvelopeError(
|
|
3100
|
+
throw new ErrorEnvelopeError(
|
|
3101
|
+
"500",
|
|
3102
|
+
response,
|
|
3103
|
+
errorBody,
|
|
3104
|
+
getErrorMessage(errorBody, "An internal server error has occurred.")
|
|
3105
|
+
);
|
|
3042
3106
|
} catch (err) {
|
|
3043
3107
|
if (err instanceof ErrorEnvelopeError) {
|
|
3044
3108
|
throw err;
|
|
@@ -3072,7 +3136,7 @@ var QueryExecutionClient = class {
|
|
|
3072
3136
|
`${response.status}`,
|
|
3073
3137
|
response,
|
|
3074
3138
|
responseValue,
|
|
3075
|
-
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
3139
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
3076
3140
|
);
|
|
3077
3141
|
}
|
|
3078
3142
|
}
|
|
@@ -3113,7 +3177,10 @@ var QueryExecutionClient = class {
|
|
|
3113
3177
|
"400",
|
|
3114
3178
|
response,
|
|
3115
3179
|
errorBody,
|
|
3116
|
-
|
|
3180
|
+
getErrorMessage(
|
|
3181
|
+
errorBody,
|
|
3182
|
+
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
3183
|
+
)
|
|
3117
3184
|
);
|
|
3118
3185
|
} catch (err) {
|
|
3119
3186
|
if (err instanceof ErrorEnvelopeError) {
|
|
@@ -3132,7 +3199,12 @@ var QueryExecutionClient = class {
|
|
|
3132
3199
|
const responseValue = await response.body("json");
|
|
3133
3200
|
try {
|
|
3134
3201
|
const errorBody = fromJson15(responseValue);
|
|
3135
|
-
throw new ErrorEnvelopeError(
|
|
3202
|
+
throw new ErrorEnvelopeError(
|
|
3203
|
+
"500",
|
|
3204
|
+
response,
|
|
3205
|
+
errorBody,
|
|
3206
|
+
getErrorMessage(errorBody, "An internal server error has occurred.")
|
|
3207
|
+
);
|
|
3136
3208
|
} catch (err) {
|
|
3137
3209
|
if (err instanceof ErrorEnvelopeError) {
|
|
3138
3210
|
throw err;
|
|
@@ -3150,7 +3222,12 @@ var QueryExecutionClient = class {
|
|
|
3150
3222
|
const responseValue = await response.body("json");
|
|
3151
3223
|
try {
|
|
3152
3224
|
const errorBody = fromJson15(responseValue);
|
|
3153
|
-
throw new ErrorEnvelopeError(
|
|
3225
|
+
throw new ErrorEnvelopeError(
|
|
3226
|
+
"503",
|
|
3227
|
+
response,
|
|
3228
|
+
errorBody,
|
|
3229
|
+
getErrorMessage(errorBody, "Service is unavailable.")
|
|
3230
|
+
);
|
|
3154
3231
|
} catch (err) {
|
|
3155
3232
|
if (err instanceof ErrorEnvelopeError) {
|
|
3156
3233
|
throw err;
|
|
@@ -3198,7 +3275,7 @@ var QueryExecutionClient = class {
|
|
|
3198
3275
|
`${response.status}`,
|
|
3199
3276
|
response,
|
|
3200
3277
|
responseValue,
|
|
3201
|
-
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
3278
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
3202
3279
|
);
|
|
3203
3280
|
}
|
|
3204
3281
|
}
|
|
@@ -3229,14 +3306,19 @@ var QueryExecutionClient = class {
|
|
|
3229
3306
|
`410`,
|
|
3230
3307
|
response,
|
|
3231
3308
|
responseValue,
|
|
3232
|
-
`The query for the given request-token is not available anymore.`
|
|
3309
|
+
getErrorMessage(responseValue, `The query for the given request-token is not available anymore.`)
|
|
3233
3310
|
);
|
|
3234
3311
|
}
|
|
3235
3312
|
case 500: {
|
|
3236
3313
|
const responseValue = await response.body("json");
|
|
3237
3314
|
try {
|
|
3238
3315
|
const errorBody = fromJson15(responseValue);
|
|
3239
|
-
throw new ErrorEnvelopeError(
|
|
3316
|
+
throw new ErrorEnvelopeError(
|
|
3317
|
+
"500",
|
|
3318
|
+
response,
|
|
3319
|
+
errorBody,
|
|
3320
|
+
getErrorMessage(errorBody, "An internal server error has occurred.")
|
|
3321
|
+
);
|
|
3240
3322
|
} catch (err) {
|
|
3241
3323
|
if (err instanceof ErrorEnvelopeError) {
|
|
3242
3324
|
throw err;
|
|
@@ -3273,7 +3355,7 @@ var QueryExecutionClient = class {
|
|
|
3273
3355
|
`${response.status}`,
|
|
3274
3356
|
response,
|
|
3275
3357
|
responseValue,
|
|
3276
|
-
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
3358
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
3277
3359
|
);
|
|
3278
3360
|
}
|
|
3279
3361
|
}
|