@dynatrace-sdk/client-query 1.20.2 → 1.21.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 +16 -0
- package/README.md +15 -12
- package/cjs/index.js +157 -397
- package/dynatrace-metadata.json +3 -3
- package/esm/index.js +64 -291
- package/package.json +2 -2
- package/types/packages/client/query/src/lib/apis/query-assistance-api.d.ts +2 -2
- package/types/packages/client/query/src/lib/apis/query-execution-api.d.ts +2 -2
- package/types/packages/client/query/src/lib/models/autocomplete-request.d.ts +4 -0
- package/types/packages/client/query/src/lib/models/autocomplete-suggestion-part.d.ts +1 -1
- package/types/packages/client/query/src/lib/models/dql-terminal-node.d.ts +1 -1
- package/types/packages/client/query/src/lib/models/error-response.d.ts +4 -0
- package/types/packages/client/query/src/lib/models/execute-request.d.ts +4 -0
- package/types/packages/client/query/src/lib/models/token-type.d.ts +9 -1
- package/types/packages/{client/query/src/lib/apis → shared-client-utils/src}/api-client-options.d.ts +1 -1
- package/types/packages/shared-client-utils/src/api-gateway-errors-handler.d.ts +9 -0
- package/types/packages/shared-client-utils/src/encoding.d.ts +17 -0
- package/types/packages/shared-client-utils/src/get-error-message.d.ts +8 -0
- package/types/packages/shared-client-utils/src/index.d.ts +6 -0
- package/types/packages/shared-client-utils/src/transformations.d.ts +64 -0
- package/types/packages/shared-client-utils/src/url-helpers.d.ts +12 -0
- package/types/packages/client/query/src/lib/error-envelopes/api-gateway-errors-handler.d.ts +0 -2
- package/types/packages/client/query/src/lib/error-envelopes/get-error-message.d.ts +0 -1
- package/types/packages/client/query/src/lib/utils/encoding.d.ts +0 -10
- package/types/packages/client/query/src/lib/utils/transformations.d.ts +0 -8
- package/types/packages/client/query/src/lib/utils/url-helpers.d.ts +0 -6
package/dynatrace-metadata.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dynagen": {
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"template": {
|
|
5
5
|
"name": "@dynatrace-sdk/template-typescript-client",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.34.0"
|
|
7
7
|
},
|
|
8
8
|
"featureFlags": {
|
|
9
9
|
"typeguards": true
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"spec": {
|
|
13
13
|
"title": "DQL Query",
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.16.0",
|
|
15
15
|
"baseUrl": "/platform/storage/query/v1"
|
|
16
16
|
}
|
|
17
17
|
}
|
package/esm/index.js
CHANGED
|
@@ -20,6 +20,12 @@ 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";
|
|
23
29
|
import {
|
|
24
30
|
ApiClientError,
|
|
25
31
|
ClientRequestError as ClientRequestError2,
|
|
@@ -27,15 +33,6 @@ import {
|
|
|
27
33
|
isInvalidResponseError
|
|
28
34
|
} from "@dynatrace-sdk/shared-errors";
|
|
29
35
|
|
|
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
|
-
|
|
39
36
|
// packages/client/query/src/lib/error-envelopes/error-envelope-error.ts
|
|
40
37
|
import { ClientRequestError } from "@dynatrace-sdk/shared-errors";
|
|
41
38
|
var ErrorEnvelopeError = class extends ClientRequestError {
|
|
@@ -45,198 +42,6 @@ function isErrorEnvelopeError(e) {
|
|
|
45
42
|
return e?.isApiClientError === true && e?.isClientRequestError === true && e?.isErrorEnvelopeError === true && e instanceof Error;
|
|
46
43
|
}
|
|
47
44
|
|
|
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
|
-
|
|
240
45
|
// packages/client/query/src/lib/apis/query-assistance-api.ts
|
|
241
46
|
var QueryAssistanceClient = class {
|
|
242
47
|
httpClient;
|
|
@@ -948,6 +753,15 @@ import {
|
|
|
948
753
|
isHttpClientAbortError as isHttpClientAbortError2,
|
|
949
754
|
isHttpClientResponseError as isHttpClientResponseError2
|
|
950
755
|
} 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";
|
|
951
765
|
import {
|
|
952
766
|
ApiClientError as ApiClientError2,
|
|
953
767
|
ClientRequestError as ClientRequestError3,
|
|
@@ -965,55 +779,6 @@ function isInsufficientPermission(e) {
|
|
|
965
779
|
return e?.isApiClientError === true && e?.isClientRequestError === true && e?.isErrorEnvelopeError === true && e?.isInsufficientPermission === true && e instanceof Error;
|
|
966
780
|
}
|
|
967
781
|
|
|
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
|
-
|
|
1017
782
|
// packages/client/query/src/lib/apis/query-execution-api.ts
|
|
1018
783
|
var QueryExecutionClient = class {
|
|
1019
784
|
httpClient;
|
|
@@ -1108,7 +873,7 @@ var QueryExecutionClient = class {
|
|
|
1108
873
|
});
|
|
1109
874
|
const responseValue = await response.body("json");
|
|
1110
875
|
try {
|
|
1111
|
-
return this.shouldTransformDates ?
|
|
876
|
+
return this.shouldTransformDates ? transformResponse2(responseValue, [
|
|
1112
877
|
["result.records.*.start", { datetime: true }],
|
|
1113
878
|
["result.records.*.end", { datetime: true }],
|
|
1114
879
|
["result.records.**.start", { datetime: true }],
|
|
@@ -1136,17 +901,17 @@ var QueryExecutionClient = class {
|
|
|
1136
901
|
throw new ApiClientError2("UnexpectedError", "Unexpected error", e);
|
|
1137
902
|
}
|
|
1138
903
|
const response = e.response;
|
|
1139
|
-
await
|
|
904
|
+
await apiGatewayErrorsHandler2(response);
|
|
1140
905
|
switch (response.status) {
|
|
1141
906
|
case 400: {
|
|
1142
907
|
const responseValue = await response.body("json");
|
|
1143
908
|
try {
|
|
1144
|
-
const errorBody = this.shouldTransformDates ?
|
|
909
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1145
910
|
throw new ErrorEnvelopeError(
|
|
1146
911
|
`400`,
|
|
1147
912
|
response,
|
|
1148
913
|
errorBody,
|
|
1149
|
-
|
|
914
|
+
getErrorMessage2(
|
|
1150
915
|
errorBody,
|
|
1151
916
|
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1152
917
|
),
|
|
@@ -1168,24 +933,24 @@ var QueryExecutionClient = class {
|
|
|
1168
933
|
}
|
|
1169
934
|
case 410: {
|
|
1170
935
|
const contentType = response.headers["content-type"];
|
|
1171
|
-
const encoding = mimeTypeToEncoding(contentType,
|
|
936
|
+
const encoding = mimeTypeToEncoding(contentType, Encoding.Text);
|
|
1172
937
|
const responseValue = await response.body(encoding);
|
|
1173
938
|
throw new ClientRequestError3(
|
|
1174
939
|
`410`,
|
|
1175
940
|
response,
|
|
1176
941
|
responseValue,
|
|
1177
|
-
|
|
942
|
+
getErrorMessage2(responseValue, `The query for the given request-token is not available anymore.`)
|
|
1178
943
|
);
|
|
1179
944
|
}
|
|
1180
945
|
case 500: {
|
|
1181
946
|
const responseValue = await response.body("json");
|
|
1182
947
|
try {
|
|
1183
|
-
const errorBody = this.shouldTransformDates ?
|
|
948
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1184
949
|
throw new ErrorEnvelopeError(
|
|
1185
950
|
`500`,
|
|
1186
951
|
response,
|
|
1187
952
|
errorBody,
|
|
1188
|
-
|
|
953
|
+
getErrorMessage2(errorBody, "An internal server error has occurred."),
|
|
1189
954
|
e
|
|
1190
955
|
);
|
|
1191
956
|
} catch (err) {
|
|
@@ -1209,7 +974,7 @@ var QueryExecutionClient = class {
|
|
|
1209
974
|
`${response.status}`,
|
|
1210
975
|
response,
|
|
1211
976
|
responseValue,
|
|
1212
|
-
|
|
977
|
+
getErrorMessage2(
|
|
1213
978
|
responseValue,
|
|
1214
979
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1215
980
|
),
|
|
@@ -1294,7 +1059,7 @@ var QueryExecutionClient = class {
|
|
|
1294
1059
|
if (!config) {
|
|
1295
1060
|
throw new ApiClientError2("API client error", "API client call is missing mandatory config parameter");
|
|
1296
1061
|
}
|
|
1297
|
-
const encodedBody = this.shouldTransformDates ?
|
|
1062
|
+
const encodedBody = this.shouldTransformDates ? transformRequest2(config.body, []) : config.body;
|
|
1298
1063
|
const query = toQueryString({ enrich: config.enrich });
|
|
1299
1064
|
const headerParameters = {
|
|
1300
1065
|
...config.dtClientContext !== void 0 && { "dt-client-context": String(config.dtClientContext) },
|
|
@@ -1322,7 +1087,7 @@ var QueryExecutionClient = class {
|
|
|
1322
1087
|
case 200: {
|
|
1323
1088
|
const responseValue = await response.body("json");
|
|
1324
1089
|
try {
|
|
1325
|
-
return this.shouldTransformDates ?
|
|
1090
|
+
return this.shouldTransformDates ? transformResponse2(responseValue, [
|
|
1326
1091
|
["result.records.*.start", { datetime: true }],
|
|
1327
1092
|
["result.records.*.end", { datetime: true }],
|
|
1328
1093
|
["result.records.**.start", { datetime: true }],
|
|
@@ -1346,7 +1111,7 @@ var QueryExecutionClient = class {
|
|
|
1346
1111
|
case 202: {
|
|
1347
1112
|
const responseValue = await response.body("json");
|
|
1348
1113
|
try {
|
|
1349
|
-
return this.shouldTransformDates ?
|
|
1114
|
+
return this.shouldTransformDates ? transformResponse2(responseValue, [
|
|
1350
1115
|
["result.records.*.start", { datetime: true }],
|
|
1351
1116
|
["result.records.*.end", { datetime: true }],
|
|
1352
1117
|
["result.records.**.start", { datetime: true }],
|
|
@@ -1374,7 +1139,7 @@ var QueryExecutionClient = class {
|
|
|
1374
1139
|
`${response.status}`,
|
|
1375
1140
|
response,
|
|
1376
1141
|
responseValue,
|
|
1377
|
-
|
|
1142
|
+
getErrorMessage2(
|
|
1378
1143
|
responseValue,
|
|
1379
1144
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1380
1145
|
)
|
|
@@ -1403,17 +1168,17 @@ var QueryExecutionClient = class {
|
|
|
1403
1168
|
throw new ApiClientError2("UnexpectedError", "Unexpected error", e);
|
|
1404
1169
|
}
|
|
1405
1170
|
const response = e.response;
|
|
1406
|
-
await
|
|
1171
|
+
await apiGatewayErrorsHandler2(response);
|
|
1407
1172
|
switch (response.status) {
|
|
1408
1173
|
case 400: {
|
|
1409
1174
|
const responseValue = await response.body("json");
|
|
1410
1175
|
try {
|
|
1411
|
-
const errorBody = this.shouldTransformDates ?
|
|
1176
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1412
1177
|
throw new ErrorEnvelopeError(
|
|
1413
1178
|
`400`,
|
|
1414
1179
|
response,
|
|
1415
1180
|
errorBody,
|
|
1416
|
-
|
|
1181
|
+
getErrorMessage2(
|
|
1417
1182
|
errorBody,
|
|
1418
1183
|
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1419
1184
|
),
|
|
@@ -1436,12 +1201,12 @@ var QueryExecutionClient = class {
|
|
|
1436
1201
|
case 403: {
|
|
1437
1202
|
const responseValue = await response.body("json");
|
|
1438
1203
|
try {
|
|
1439
|
-
const errorBody = this.shouldTransformDates ?
|
|
1204
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1440
1205
|
throw new InsufficientPermission(
|
|
1441
1206
|
`403`,
|
|
1442
1207
|
response,
|
|
1443
1208
|
errorBody,
|
|
1444
|
-
|
|
1209
|
+
getErrorMessage2(errorBody, "Insufficient permissions."),
|
|
1445
1210
|
e
|
|
1446
1211
|
);
|
|
1447
1212
|
} catch (err) {
|
|
@@ -1461,12 +1226,12 @@ var QueryExecutionClient = class {
|
|
|
1461
1226
|
case 429: {
|
|
1462
1227
|
const responseValue = await response.body("json");
|
|
1463
1228
|
try {
|
|
1464
|
-
const errorBody = this.shouldTransformDates ?
|
|
1229
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1465
1230
|
throw new ErrorEnvelopeError(
|
|
1466
1231
|
`429`,
|
|
1467
1232
|
response,
|
|
1468
1233
|
errorBody,
|
|
1469
|
-
|
|
1234
|
+
getErrorMessage2(errorBody, "Too many requests."),
|
|
1470
1235
|
e
|
|
1471
1236
|
);
|
|
1472
1237
|
} catch (err) {
|
|
@@ -1486,12 +1251,12 @@ var QueryExecutionClient = class {
|
|
|
1486
1251
|
case 500: {
|
|
1487
1252
|
const responseValue = await response.body("json");
|
|
1488
1253
|
try {
|
|
1489
|
-
const errorBody = this.shouldTransformDates ?
|
|
1254
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1490
1255
|
throw new ErrorEnvelopeError(
|
|
1491
1256
|
`500`,
|
|
1492
1257
|
response,
|
|
1493
1258
|
errorBody,
|
|
1494
|
-
|
|
1259
|
+
getErrorMessage2(errorBody, "An internal server error has occurred."),
|
|
1495
1260
|
e
|
|
1496
1261
|
);
|
|
1497
1262
|
} catch (err) {
|
|
@@ -1511,12 +1276,12 @@ var QueryExecutionClient = class {
|
|
|
1511
1276
|
case 503: {
|
|
1512
1277
|
const responseValue = await response.body("json");
|
|
1513
1278
|
try {
|
|
1514
|
-
const errorBody = this.shouldTransformDates ?
|
|
1279
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1515
1280
|
throw new ErrorEnvelopeError(
|
|
1516
1281
|
`503`,
|
|
1517
1282
|
response,
|
|
1518
1283
|
errorBody,
|
|
1519
|
-
|
|
1284
|
+
getErrorMessage2(errorBody, "Service is unavailable."),
|
|
1520
1285
|
e
|
|
1521
1286
|
);
|
|
1522
1287
|
} catch (err) {
|
|
@@ -1537,12 +1302,12 @@ var QueryExecutionClient = class {
|
|
|
1537
1302
|
if (response.status >= 400 && response.status <= 499) {
|
|
1538
1303
|
const responseValue = await response.body("json");
|
|
1539
1304
|
try {
|
|
1540
|
-
const errorBody = this.shouldTransformDates ?
|
|
1305
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1541
1306
|
throw new ErrorEnvelopeError(
|
|
1542
1307
|
`${response.status}`,
|
|
1543
1308
|
response,
|
|
1544
1309
|
errorBody,
|
|
1545
|
-
|
|
1310
|
+
getErrorMessage2(errorBody, "Client error."),
|
|
1546
1311
|
e
|
|
1547
1312
|
);
|
|
1548
1313
|
} catch (err) {
|
|
@@ -1561,12 +1326,12 @@ var QueryExecutionClient = class {
|
|
|
1561
1326
|
} else if (response.status >= 500 && response.status <= 599) {
|
|
1562
1327
|
const responseValue = await response.body("json");
|
|
1563
1328
|
try {
|
|
1564
|
-
const errorBody = this.shouldTransformDates ?
|
|
1329
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1565
1330
|
throw new ErrorEnvelopeError(
|
|
1566
1331
|
`${response.status}`,
|
|
1567
1332
|
response,
|
|
1568
1333
|
errorBody,
|
|
1569
|
-
|
|
1334
|
+
getErrorMessage2(errorBody, "Server error."),
|
|
1570
1335
|
e
|
|
1571
1336
|
);
|
|
1572
1337
|
} catch (err) {
|
|
@@ -1589,7 +1354,7 @@ var QueryExecutionClient = class {
|
|
|
1589
1354
|
`${response.status}`,
|
|
1590
1355
|
response,
|
|
1591
1356
|
responseValue,
|
|
1592
|
-
|
|
1357
|
+
getErrorMessage2(
|
|
1593
1358
|
responseValue,
|
|
1594
1359
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1595
1360
|
)
|
|
@@ -1693,7 +1458,7 @@ var QueryExecutionClient = class {
|
|
|
1693
1458
|
case 200: {
|
|
1694
1459
|
const responseValue = await response.body("json");
|
|
1695
1460
|
try {
|
|
1696
|
-
return this.shouldTransformDates ?
|
|
1461
|
+
return this.shouldTransformDates ? transformResponse2(responseValue, [
|
|
1697
1462
|
["result.records.*.start", { datetime: true }],
|
|
1698
1463
|
["result.records.*.end", { datetime: true }],
|
|
1699
1464
|
["result.records.**.start", { datetime: true }],
|
|
@@ -1724,7 +1489,7 @@ var QueryExecutionClient = class {
|
|
|
1724
1489
|
`${response.status}`,
|
|
1725
1490
|
response,
|
|
1726
1491
|
responseValue,
|
|
1727
|
-
|
|
1492
|
+
getErrorMessage2(
|
|
1728
1493
|
responseValue,
|
|
1729
1494
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1730
1495
|
)
|
|
@@ -1753,17 +1518,17 @@ var QueryExecutionClient = class {
|
|
|
1753
1518
|
throw new ApiClientError2("UnexpectedError", "Unexpected error", e);
|
|
1754
1519
|
}
|
|
1755
1520
|
const response = e.response;
|
|
1756
|
-
await
|
|
1521
|
+
await apiGatewayErrorsHandler2(response);
|
|
1757
1522
|
switch (response.status) {
|
|
1758
1523
|
case 400: {
|
|
1759
1524
|
const responseValue = await response.body("json");
|
|
1760
1525
|
try {
|
|
1761
|
-
const errorBody = this.shouldTransformDates ?
|
|
1526
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1762
1527
|
throw new ErrorEnvelopeError(
|
|
1763
1528
|
`400`,
|
|
1764
1529
|
response,
|
|
1765
1530
|
errorBody,
|
|
1766
|
-
|
|
1531
|
+
getErrorMessage2(
|
|
1767
1532
|
errorBody,
|
|
1768
1533
|
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1769
1534
|
),
|
|
@@ -1785,24 +1550,24 @@ var QueryExecutionClient = class {
|
|
|
1785
1550
|
}
|
|
1786
1551
|
case 410: {
|
|
1787
1552
|
const contentType = response.headers["content-type"];
|
|
1788
|
-
const encoding = mimeTypeToEncoding(contentType,
|
|
1553
|
+
const encoding = mimeTypeToEncoding(contentType, Encoding.Text);
|
|
1789
1554
|
const responseValue = await response.body(encoding);
|
|
1790
1555
|
throw new ClientRequestError3(
|
|
1791
1556
|
`410`,
|
|
1792
1557
|
response,
|
|
1793
1558
|
responseValue,
|
|
1794
|
-
|
|
1559
|
+
getErrorMessage2(responseValue, `The query for the given request-token is not available anymore.`)
|
|
1795
1560
|
);
|
|
1796
1561
|
}
|
|
1797
1562
|
case 500: {
|
|
1798
1563
|
const responseValue = await response.body("json");
|
|
1799
1564
|
try {
|
|
1800
|
-
const errorBody = this.shouldTransformDates ?
|
|
1565
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1801
1566
|
throw new ErrorEnvelopeError(
|
|
1802
1567
|
`500`,
|
|
1803
1568
|
response,
|
|
1804
1569
|
errorBody,
|
|
1805
|
-
|
|
1570
|
+
getErrorMessage2(errorBody, "An internal server error has occurred."),
|
|
1806
1571
|
e
|
|
1807
1572
|
);
|
|
1808
1573
|
} catch (err) {
|
|
@@ -1826,7 +1591,7 @@ var QueryExecutionClient = class {
|
|
|
1826
1591
|
`${response.status}`,
|
|
1827
1592
|
response,
|
|
1828
1593
|
responseValue,
|
|
1829
|
-
|
|
1594
|
+
getErrorMessage2(
|
|
1830
1595
|
responseValue,
|
|
1831
1596
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1832
1597
|
),
|
|
@@ -1856,7 +1621,7 @@ var queryExecutionClient = /* @__PURE__ */ new QueryExecutionClient(defaultHttpC
|
|
|
1856
1621
|
// packages/client/query/src/lib/error-envelopes/index.ts
|
|
1857
1622
|
import {
|
|
1858
1623
|
ApiClientError as ApiClientError3,
|
|
1859
|
-
ApiGatewayError
|
|
1624
|
+
ApiGatewayError,
|
|
1860
1625
|
ClientRequestError as ClientRequestError4,
|
|
1861
1626
|
InvalidResponseError as InvalidResponseError3,
|
|
1862
1627
|
isApiClientError,
|
|
@@ -1952,16 +1717,24 @@ var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
|
1952
1717
|
TokenType2["SearchPattern"] = "SEARCH_PATTERN";
|
|
1953
1718
|
TokenType2["EntitySelectorPart"] = "ENTITY_SELECTOR_PART";
|
|
1954
1719
|
TokenType2["SavedTableName"] = "SAVED_TABLE_NAME";
|
|
1720
|
+
TokenType2["TabularFileName"] = "TABULAR_FILE_NAME";
|
|
1955
1721
|
TokenType2["ParameterModifier"] = "PARAMETER_MODIFIER";
|
|
1956
1722
|
TokenType2["FieldModifier"] = "FIELD_MODIFIER";
|
|
1957
1723
|
TokenType2["EntityType"] = "ENTITY_TYPE";
|
|
1958
1724
|
TokenType2["EntityAttribute"] = "ENTITY_ATTRIBUTE";
|
|
1959
1725
|
TokenType2["SmartscapeIdValue"] = "SMARTSCAPE_ID_VALUE";
|
|
1726
|
+
TokenType2["EnumString"] = "ENUM_STRING";
|
|
1727
|
+
TokenType2["FieldPrefix"] = "FIELD_PREFIX";
|
|
1728
|
+
TokenType2["Bucket"] = "BUCKET";
|
|
1729
|
+
TokenType2["SmartscapeNodePattern"] = "SMARTSCAPE_NODE_PATTERN";
|
|
1730
|
+
TokenType2["SmartscapeEdgePattern"] = "SMARTSCAPE_EDGE_PATTERN";
|
|
1731
|
+
TokenType2["SmartscapeNodeType"] = "SMARTSCAPE_NODE_TYPE";
|
|
1732
|
+
TokenType2["SmartscapeEdgeType"] = "SMARTSCAPE_EDGE_TYPE";
|
|
1960
1733
|
return TokenType2;
|
|
1961
1734
|
})(TokenType || {});
|
|
1962
1735
|
export {
|
|
1963
1736
|
ApiClientError3 as ApiClientError,
|
|
1964
|
-
|
|
1737
|
+
ApiGatewayError,
|
|
1965
1738
|
ClientRequestError4 as ClientRequestError,
|
|
1966
1739
|
DQLNodeNodeType,
|
|
1967
1740
|
ErrorEnvelopeError,
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynatrace-sdk/client-query",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.1",
|
|
4
4
|
"description": "Exposes an API to fetch records stored in Grail.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynatrace-sdk/error-handlers": "^1.2.0",
|
|
8
7
|
"@dynatrace-sdk/http-client": "^1.3.0",
|
|
8
|
+
"@dynatrace-sdk/shared-client-utils": "^1.0.1",
|
|
9
9
|
"@dynatrace-sdk/shared-errors": "^1.0.0"
|
|
10
10
|
},
|
|
11
11
|
"main": "./cjs/index.js",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AbortSignal, HttpClient } from '@dynatrace-sdk/http-client';
|
|
2
|
+
import { ApiClientOptions } from '@dynatrace-sdk/shared-client-utils';
|
|
2
3
|
import { AutocompleteRequest } from '../models/autocomplete-request';
|
|
3
4
|
import { AutocompleteResponse } from '../models/autocomplete-response';
|
|
4
5
|
import { DQLNode } from '../models/dql-node';
|
|
5
6
|
import { ParseRequest } from '../models/parse-request';
|
|
6
7
|
import { VerifyRequest } from '../models/verify-request';
|
|
7
8
|
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
|
*/
|
|
@@ -327,7 +327,7 @@ export declare class QueryAssistanceClient {
|
|
|
327
327
|
queryAutocomplete(config: {
|
|
328
328
|
body: AutocompleteRequest;
|
|
329
329
|
/** The dt-client-context header is an optional string parameter used for monitoring purposes. When included in a request, it helps retrieve information about the execution of the query. It shouldn't hold sensitive information. */ dtClientContext?: string;
|
|
330
|
-
/** If set, query consumption limit will be enforced. */ enforceQueryConsumptionLimit?: boolean;
|
|
330
|
+
/** (DEPRECATED use body parameter 'enforceQueryConsumptionLimit' instead) If set, query consumption limit will be enforced. */ enforceQueryConsumptionLimit?: boolean;
|
|
331
331
|
abortSignal?: AbortSignal;
|
|
332
332
|
}): Promise<AutocompleteResponse>;
|
|
333
333
|
}
|