@dynatrace-sdk/client-query 1.20.0 → 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 +30 -0
- package/README.md +15 -12
- package/cjs/index.js +157 -342
- package/dynatrace-metadata.json +3 -4
- package/esm/index.js +64 -236
- 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 -7
- package/types/packages/client/query/src/lib/utils/url-helpers.d.ts +0 -6
package/dynatrace-metadata.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dynagen": {
|
|
3
|
-
"version": "0.
|
|
4
|
-
"generatedAt": "2025-03-31T11:21:40.514Z",
|
|
3
|
+
"version": "0.19.3",
|
|
5
4
|
"template": {
|
|
6
5
|
"name": "@dynatrace-sdk/template-typescript-client",
|
|
7
|
-
"version": "0.
|
|
6
|
+
"version": "0.34.0"
|
|
8
7
|
},
|
|
9
8
|
"featureFlags": {
|
|
10
9
|
"typeguards": true
|
|
@@ -12,7 +11,7 @@
|
|
|
12
11
|
},
|
|
13
12
|
"spec": {
|
|
14
13
|
"title": "DQL Query",
|
|
15
|
-
"version": "1.
|
|
14
|
+
"version": "1.16.0",
|
|
16
15
|
"baseUrl": "/platform/storage/query/v1"
|
|
17
16
|
}
|
|
18
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,143 +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, keys) {
|
|
92
|
-
const match = keys.find((k) => {
|
|
93
|
-
const ruleKey = Array.isArray(k) ? k[0] : k;
|
|
94
|
-
if (key === ruleKey) {
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
if (!key || !ruleKey) {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
const [keyParts, ruleKeyParts] = [key.split("."), ruleKey.split(".")];
|
|
101
|
-
const [keyPartsReversed, ruleKeyPartsReversed] = [[...keyParts].reverse(), [...ruleKeyParts].reverse()];
|
|
102
|
-
let wildcard = false;
|
|
103
|
-
let matchResult = true;
|
|
104
|
-
keyParts.forEach((keyPart, idx) => {
|
|
105
|
-
if (keyPart !== ruleKeyParts[idx] && !wildcard) {
|
|
106
|
-
if (ruleKeyParts[idx] === "**") {
|
|
107
|
-
wildcard = true;
|
|
108
|
-
} else if (ruleKeyParts[idx] === "*") {
|
|
109
|
-
wildcard = true;
|
|
110
|
-
} else {
|
|
111
|
-
matchResult = false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
wildcard = false;
|
|
116
|
-
keyPartsReversed.forEach((keyPart, idx) => {
|
|
117
|
-
if (keyPart !== ruleKeyPartsReversed[idx] && !wildcard) {
|
|
118
|
-
if (ruleKeyPartsReversed[idx] === "**") {
|
|
119
|
-
wildcard = true;
|
|
120
|
-
} else if (ruleKeyPartsReversed[idx] === "*") {
|
|
121
|
-
wildcard = true;
|
|
122
|
-
} else {
|
|
123
|
-
matchResult = false;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return matchResult;
|
|
128
|
-
});
|
|
129
|
-
if (match) {
|
|
130
|
-
return Array.isArray(match) ? match : [match, defaultRuleConfig];
|
|
131
|
-
}
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
var dateTimePattern = /^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[+-]\d{2}:\d{2})?)$/i;
|
|
135
|
-
function isDateLike(value) {
|
|
136
|
-
if (typeof value === "string") {
|
|
137
|
-
return dateTimePattern.test(value);
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
function transformValue(value, rules, direction) {
|
|
142
|
-
const { force, datetime } = rules;
|
|
143
|
-
if (direction === "to") {
|
|
144
|
-
return force || isDateLike(value) ? new Date(value) : value;
|
|
145
|
-
}
|
|
146
|
-
if (value instanceof Date) {
|
|
147
|
-
const iso = value.toISOString();
|
|
148
|
-
return datetime ? iso : iso.split("T")[0];
|
|
149
|
-
}
|
|
150
|
-
return value;
|
|
151
|
-
}
|
|
152
|
-
function transform(direction, object, keys) {
|
|
153
|
-
function walk(obj, currentKey = "") {
|
|
154
|
-
if (Array.isArray(obj)) {
|
|
155
|
-
obj.forEach((item, idx) => {
|
|
156
|
-
const match = matchKey(currentKey, keys);
|
|
157
|
-
if (typeof item === "object" && item !== null) {
|
|
158
|
-
walk(item, currentKey);
|
|
159
|
-
} else if (match) {
|
|
160
|
-
obj[idx] = transformValue(obj[idx], match[1], direction);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
if (typeof obj === "object" && obj !== null && !Array.isArray(obj)) {
|
|
165
|
-
for (const key of Object.keys(obj)) {
|
|
166
|
-
const mergedKey = mergeKeys(currentKey, key);
|
|
167
|
-
const match = matchKey(mergedKey, keys);
|
|
168
|
-
if (match) {
|
|
169
|
-
obj[key] = transformValue(obj[key], match[1], direction);
|
|
170
|
-
}
|
|
171
|
-
walk(obj[key], mergedKey);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return obj;
|
|
175
|
-
}
|
|
176
|
-
return walk(object);
|
|
177
|
-
}
|
|
178
|
-
function transformRequest(object, keys) {
|
|
179
|
-
return transform("from", object, keys);
|
|
180
|
-
}
|
|
181
|
-
function transformResponse(object, keys) {
|
|
182
|
-
return transform("to", object, keys);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
45
|
// packages/client/query/src/lib/apis/query-assistance-api.ts
|
|
186
46
|
var QueryAssistanceClient = class {
|
|
187
47
|
httpClient;
|
|
@@ -893,6 +753,15 @@ import {
|
|
|
893
753
|
isHttpClientAbortError as isHttpClientAbortError2,
|
|
894
754
|
isHttpClientResponseError as isHttpClientResponseError2
|
|
895
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";
|
|
896
765
|
import {
|
|
897
766
|
ApiClientError as ApiClientError2,
|
|
898
767
|
ClientRequestError as ClientRequestError3,
|
|
@@ -910,55 +779,6 @@ function isInsufficientPermission(e) {
|
|
|
910
779
|
return e?.isApiClientError === true && e?.isClientRequestError === true && e?.isErrorEnvelopeError === true && e?.isInsufficientPermission === true && e instanceof Error;
|
|
911
780
|
}
|
|
912
781
|
|
|
913
|
-
// packages/client/query/src/lib/utils/encoding.ts
|
|
914
|
-
function mimeTypeToEncoding(mimeType, defaultEncoding) {
|
|
915
|
-
const shortMimeType = mimeType.split(";")[0];
|
|
916
|
-
switch (shortMimeType) {
|
|
917
|
-
case "application/json":
|
|
918
|
-
case "application/cloudevent+json":
|
|
919
|
-
case "application/cloudevent-batch+json":
|
|
920
|
-
return "json" /* Json */;
|
|
921
|
-
case "text/plain":
|
|
922
|
-
return "text" /* Text */;
|
|
923
|
-
case "application/octet-stream":
|
|
924
|
-
return "binary" /* Binary */;
|
|
925
|
-
case "multipart/form-data":
|
|
926
|
-
return "form-data" /* FormData */;
|
|
927
|
-
default:
|
|
928
|
-
if (defaultEncoding)
|
|
929
|
-
return defaultEncoding;
|
|
930
|
-
else
|
|
931
|
-
throw new Error(`${shortMimeType} mime type is not yet supported`);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
// packages/client/query/src/lib/utils/url-helpers.ts
|
|
936
|
-
var encodeQueryParam = (key, value) => {
|
|
937
|
-
const encodedKey = encodeURIComponent(key);
|
|
938
|
-
return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : String(value))}`;
|
|
939
|
-
};
|
|
940
|
-
var addExplodedArrayQueryParam = (query, key) => {
|
|
941
|
-
const arrayValue = query[key];
|
|
942
|
-
return arrayValue.map((value) => encodeQueryParam(key, value)).join("&");
|
|
943
|
-
};
|
|
944
|
-
var addNonExplodedArrayQueryParams = (query, key) => {
|
|
945
|
-
const encodedKey = encodeURIComponent(key);
|
|
946
|
-
const encodedParamsList = query[key].map((value) => encodeURIComponent(typeof value === "number" ? value : String(value))).join(",");
|
|
947
|
-
return `${encodedKey}=${encodedParamsList}`;
|
|
948
|
-
};
|
|
949
|
-
var addQueryParam = (query, key) => encodeQueryParam(key, query[key]);
|
|
950
|
-
var arrayQueryParams = (query, key, explode) => {
|
|
951
|
-
return explode ? addExplodedArrayQueryParam(query, key) : addNonExplodedArrayQueryParams(query, key);
|
|
952
|
-
};
|
|
953
|
-
var toQueryString = (rawQuery, flags = {}) => {
|
|
954
|
-
const query = rawQuery || {};
|
|
955
|
-
const keys = Object.keys(query).filter((key) => typeof query[key] !== "undefined");
|
|
956
|
-
const queryString = keys.map(
|
|
957
|
-
(key) => Array.isArray(query[key]) ? arrayQueryParams(query, key, flags.explode?.hasOwnProperty(key) ? flags.explode[key] : true) : addQueryParam(query, key)
|
|
958
|
-
).join("&");
|
|
959
|
-
return queryString ? `?${queryString}` : "";
|
|
960
|
-
};
|
|
961
|
-
|
|
962
782
|
// packages/client/query/src/lib/apis/query-execution-api.ts
|
|
963
783
|
var QueryExecutionClient = class {
|
|
964
784
|
httpClient;
|
|
@@ -1053,7 +873,7 @@ var QueryExecutionClient = class {
|
|
|
1053
873
|
});
|
|
1054
874
|
const responseValue = await response.body("json");
|
|
1055
875
|
try {
|
|
1056
|
-
return this.shouldTransformDates ?
|
|
876
|
+
return this.shouldTransformDates ? transformResponse2(responseValue, [
|
|
1057
877
|
["result.records.*.start", { datetime: true }],
|
|
1058
878
|
["result.records.*.end", { datetime: true }],
|
|
1059
879
|
["result.records.**.start", { datetime: true }],
|
|
@@ -1081,17 +901,17 @@ var QueryExecutionClient = class {
|
|
|
1081
901
|
throw new ApiClientError2("UnexpectedError", "Unexpected error", e);
|
|
1082
902
|
}
|
|
1083
903
|
const response = e.response;
|
|
1084
|
-
await
|
|
904
|
+
await apiGatewayErrorsHandler2(response);
|
|
1085
905
|
switch (response.status) {
|
|
1086
906
|
case 400: {
|
|
1087
907
|
const responseValue = await response.body("json");
|
|
1088
908
|
try {
|
|
1089
|
-
const errorBody = this.shouldTransformDates ?
|
|
909
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1090
910
|
throw new ErrorEnvelopeError(
|
|
1091
911
|
`400`,
|
|
1092
912
|
response,
|
|
1093
913
|
errorBody,
|
|
1094
|
-
|
|
914
|
+
getErrorMessage2(
|
|
1095
915
|
errorBody,
|
|
1096
916
|
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1097
917
|
),
|
|
@@ -1113,24 +933,24 @@ var QueryExecutionClient = class {
|
|
|
1113
933
|
}
|
|
1114
934
|
case 410: {
|
|
1115
935
|
const contentType = response.headers["content-type"];
|
|
1116
|
-
const encoding = mimeTypeToEncoding(contentType,
|
|
936
|
+
const encoding = mimeTypeToEncoding(contentType, Encoding.Text);
|
|
1117
937
|
const responseValue = await response.body(encoding);
|
|
1118
938
|
throw new ClientRequestError3(
|
|
1119
939
|
`410`,
|
|
1120
940
|
response,
|
|
1121
941
|
responseValue,
|
|
1122
|
-
|
|
942
|
+
getErrorMessage2(responseValue, `The query for the given request-token is not available anymore.`)
|
|
1123
943
|
);
|
|
1124
944
|
}
|
|
1125
945
|
case 500: {
|
|
1126
946
|
const responseValue = await response.body("json");
|
|
1127
947
|
try {
|
|
1128
|
-
const errorBody = this.shouldTransformDates ?
|
|
948
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1129
949
|
throw new ErrorEnvelopeError(
|
|
1130
950
|
`500`,
|
|
1131
951
|
response,
|
|
1132
952
|
errorBody,
|
|
1133
|
-
|
|
953
|
+
getErrorMessage2(errorBody, "An internal server error has occurred."),
|
|
1134
954
|
e
|
|
1135
955
|
);
|
|
1136
956
|
} catch (err) {
|
|
@@ -1154,7 +974,7 @@ var QueryExecutionClient = class {
|
|
|
1154
974
|
`${response.status}`,
|
|
1155
975
|
response,
|
|
1156
976
|
responseValue,
|
|
1157
|
-
|
|
977
|
+
getErrorMessage2(
|
|
1158
978
|
responseValue,
|
|
1159
979
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1160
980
|
),
|
|
@@ -1239,7 +1059,7 @@ var QueryExecutionClient = class {
|
|
|
1239
1059
|
if (!config) {
|
|
1240
1060
|
throw new ApiClientError2("API client error", "API client call is missing mandatory config parameter");
|
|
1241
1061
|
}
|
|
1242
|
-
const encodedBody = this.shouldTransformDates ?
|
|
1062
|
+
const encodedBody = this.shouldTransformDates ? transformRequest2(config.body, []) : config.body;
|
|
1243
1063
|
const query = toQueryString({ enrich: config.enrich });
|
|
1244
1064
|
const headerParameters = {
|
|
1245
1065
|
...config.dtClientContext !== void 0 && { "dt-client-context": String(config.dtClientContext) },
|
|
@@ -1267,7 +1087,7 @@ var QueryExecutionClient = class {
|
|
|
1267
1087
|
case 200: {
|
|
1268
1088
|
const responseValue = await response.body("json");
|
|
1269
1089
|
try {
|
|
1270
|
-
return this.shouldTransformDates ?
|
|
1090
|
+
return this.shouldTransformDates ? transformResponse2(responseValue, [
|
|
1271
1091
|
["result.records.*.start", { datetime: true }],
|
|
1272
1092
|
["result.records.*.end", { datetime: true }],
|
|
1273
1093
|
["result.records.**.start", { datetime: true }],
|
|
@@ -1291,7 +1111,7 @@ var QueryExecutionClient = class {
|
|
|
1291
1111
|
case 202: {
|
|
1292
1112
|
const responseValue = await response.body("json");
|
|
1293
1113
|
try {
|
|
1294
|
-
return this.shouldTransformDates ?
|
|
1114
|
+
return this.shouldTransformDates ? transformResponse2(responseValue, [
|
|
1295
1115
|
["result.records.*.start", { datetime: true }],
|
|
1296
1116
|
["result.records.*.end", { datetime: true }],
|
|
1297
1117
|
["result.records.**.start", { datetime: true }],
|
|
@@ -1319,7 +1139,7 @@ var QueryExecutionClient = class {
|
|
|
1319
1139
|
`${response.status}`,
|
|
1320
1140
|
response,
|
|
1321
1141
|
responseValue,
|
|
1322
|
-
|
|
1142
|
+
getErrorMessage2(
|
|
1323
1143
|
responseValue,
|
|
1324
1144
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1325
1145
|
)
|
|
@@ -1348,17 +1168,17 @@ var QueryExecutionClient = class {
|
|
|
1348
1168
|
throw new ApiClientError2("UnexpectedError", "Unexpected error", e);
|
|
1349
1169
|
}
|
|
1350
1170
|
const response = e.response;
|
|
1351
|
-
await
|
|
1171
|
+
await apiGatewayErrorsHandler2(response);
|
|
1352
1172
|
switch (response.status) {
|
|
1353
1173
|
case 400: {
|
|
1354
1174
|
const responseValue = await response.body("json");
|
|
1355
1175
|
try {
|
|
1356
|
-
const errorBody = this.shouldTransformDates ?
|
|
1176
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1357
1177
|
throw new ErrorEnvelopeError(
|
|
1358
1178
|
`400`,
|
|
1359
1179
|
response,
|
|
1360
1180
|
errorBody,
|
|
1361
|
-
|
|
1181
|
+
getErrorMessage2(
|
|
1362
1182
|
errorBody,
|
|
1363
1183
|
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1364
1184
|
),
|
|
@@ -1381,12 +1201,12 @@ var QueryExecutionClient = class {
|
|
|
1381
1201
|
case 403: {
|
|
1382
1202
|
const responseValue = await response.body("json");
|
|
1383
1203
|
try {
|
|
1384
|
-
const errorBody = this.shouldTransformDates ?
|
|
1204
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1385
1205
|
throw new InsufficientPermission(
|
|
1386
1206
|
`403`,
|
|
1387
1207
|
response,
|
|
1388
1208
|
errorBody,
|
|
1389
|
-
|
|
1209
|
+
getErrorMessage2(errorBody, "Insufficient permissions."),
|
|
1390
1210
|
e
|
|
1391
1211
|
);
|
|
1392
1212
|
} catch (err) {
|
|
@@ -1406,12 +1226,12 @@ var QueryExecutionClient = class {
|
|
|
1406
1226
|
case 429: {
|
|
1407
1227
|
const responseValue = await response.body("json");
|
|
1408
1228
|
try {
|
|
1409
|
-
const errorBody = this.shouldTransformDates ?
|
|
1229
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1410
1230
|
throw new ErrorEnvelopeError(
|
|
1411
1231
|
`429`,
|
|
1412
1232
|
response,
|
|
1413
1233
|
errorBody,
|
|
1414
|
-
|
|
1234
|
+
getErrorMessage2(errorBody, "Too many requests."),
|
|
1415
1235
|
e
|
|
1416
1236
|
);
|
|
1417
1237
|
} catch (err) {
|
|
@@ -1431,12 +1251,12 @@ var QueryExecutionClient = class {
|
|
|
1431
1251
|
case 500: {
|
|
1432
1252
|
const responseValue = await response.body("json");
|
|
1433
1253
|
try {
|
|
1434
|
-
const errorBody = this.shouldTransformDates ?
|
|
1254
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1435
1255
|
throw new ErrorEnvelopeError(
|
|
1436
1256
|
`500`,
|
|
1437
1257
|
response,
|
|
1438
1258
|
errorBody,
|
|
1439
|
-
|
|
1259
|
+
getErrorMessage2(errorBody, "An internal server error has occurred."),
|
|
1440
1260
|
e
|
|
1441
1261
|
);
|
|
1442
1262
|
} catch (err) {
|
|
@@ -1456,12 +1276,12 @@ var QueryExecutionClient = class {
|
|
|
1456
1276
|
case 503: {
|
|
1457
1277
|
const responseValue = await response.body("json");
|
|
1458
1278
|
try {
|
|
1459
|
-
const errorBody = this.shouldTransformDates ?
|
|
1279
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1460
1280
|
throw new ErrorEnvelopeError(
|
|
1461
1281
|
`503`,
|
|
1462
1282
|
response,
|
|
1463
1283
|
errorBody,
|
|
1464
|
-
|
|
1284
|
+
getErrorMessage2(errorBody, "Service is unavailable."),
|
|
1465
1285
|
e
|
|
1466
1286
|
);
|
|
1467
1287
|
} catch (err) {
|
|
@@ -1482,12 +1302,12 @@ var QueryExecutionClient = class {
|
|
|
1482
1302
|
if (response.status >= 400 && response.status <= 499) {
|
|
1483
1303
|
const responseValue = await response.body("json");
|
|
1484
1304
|
try {
|
|
1485
|
-
const errorBody = this.shouldTransformDates ?
|
|
1305
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1486
1306
|
throw new ErrorEnvelopeError(
|
|
1487
1307
|
`${response.status}`,
|
|
1488
1308
|
response,
|
|
1489
1309
|
errorBody,
|
|
1490
|
-
|
|
1310
|
+
getErrorMessage2(errorBody, "Client error."),
|
|
1491
1311
|
e
|
|
1492
1312
|
);
|
|
1493
1313
|
} catch (err) {
|
|
@@ -1506,12 +1326,12 @@ var QueryExecutionClient = class {
|
|
|
1506
1326
|
} else if (response.status >= 500 && response.status <= 599) {
|
|
1507
1327
|
const responseValue = await response.body("json");
|
|
1508
1328
|
try {
|
|
1509
|
-
const errorBody = this.shouldTransformDates ?
|
|
1329
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1510
1330
|
throw new ErrorEnvelopeError(
|
|
1511
1331
|
`${response.status}`,
|
|
1512
1332
|
response,
|
|
1513
1333
|
errorBody,
|
|
1514
|
-
|
|
1334
|
+
getErrorMessage2(errorBody, "Server error."),
|
|
1515
1335
|
e
|
|
1516
1336
|
);
|
|
1517
1337
|
} catch (err) {
|
|
@@ -1534,7 +1354,7 @@ var QueryExecutionClient = class {
|
|
|
1534
1354
|
`${response.status}`,
|
|
1535
1355
|
response,
|
|
1536
1356
|
responseValue,
|
|
1537
|
-
|
|
1357
|
+
getErrorMessage2(
|
|
1538
1358
|
responseValue,
|
|
1539
1359
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1540
1360
|
)
|
|
@@ -1638,7 +1458,7 @@ var QueryExecutionClient = class {
|
|
|
1638
1458
|
case 200: {
|
|
1639
1459
|
const responseValue = await response.body("json");
|
|
1640
1460
|
try {
|
|
1641
|
-
return this.shouldTransformDates ?
|
|
1461
|
+
return this.shouldTransformDates ? transformResponse2(responseValue, [
|
|
1642
1462
|
["result.records.*.start", { datetime: true }],
|
|
1643
1463
|
["result.records.*.end", { datetime: true }],
|
|
1644
1464
|
["result.records.**.start", { datetime: true }],
|
|
@@ -1669,7 +1489,7 @@ var QueryExecutionClient = class {
|
|
|
1669
1489
|
`${response.status}`,
|
|
1670
1490
|
response,
|
|
1671
1491
|
responseValue,
|
|
1672
|
-
|
|
1492
|
+
getErrorMessage2(
|
|
1673
1493
|
responseValue,
|
|
1674
1494
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1675
1495
|
)
|
|
@@ -1698,17 +1518,17 @@ var QueryExecutionClient = class {
|
|
|
1698
1518
|
throw new ApiClientError2("UnexpectedError", "Unexpected error", e);
|
|
1699
1519
|
}
|
|
1700
1520
|
const response = e.response;
|
|
1701
|
-
await
|
|
1521
|
+
await apiGatewayErrorsHandler2(response);
|
|
1702
1522
|
switch (response.status) {
|
|
1703
1523
|
case 400: {
|
|
1704
1524
|
const responseValue = await response.body("json");
|
|
1705
1525
|
try {
|
|
1706
|
-
const errorBody = this.shouldTransformDates ?
|
|
1526
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1707
1527
|
throw new ErrorEnvelopeError(
|
|
1708
1528
|
`400`,
|
|
1709
1529
|
response,
|
|
1710
1530
|
errorBody,
|
|
1711
|
-
|
|
1531
|
+
getErrorMessage2(
|
|
1712
1532
|
errorBody,
|
|
1713
1533
|
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1714
1534
|
),
|
|
@@ -1730,24 +1550,24 @@ var QueryExecutionClient = class {
|
|
|
1730
1550
|
}
|
|
1731
1551
|
case 410: {
|
|
1732
1552
|
const contentType = response.headers["content-type"];
|
|
1733
|
-
const encoding = mimeTypeToEncoding(contentType,
|
|
1553
|
+
const encoding = mimeTypeToEncoding(contentType, Encoding.Text);
|
|
1734
1554
|
const responseValue = await response.body(encoding);
|
|
1735
1555
|
throw new ClientRequestError3(
|
|
1736
1556
|
`410`,
|
|
1737
1557
|
response,
|
|
1738
1558
|
responseValue,
|
|
1739
|
-
|
|
1559
|
+
getErrorMessage2(responseValue, `The query for the given request-token is not available anymore.`)
|
|
1740
1560
|
);
|
|
1741
1561
|
}
|
|
1742
1562
|
case 500: {
|
|
1743
1563
|
const responseValue = await response.body("json");
|
|
1744
1564
|
try {
|
|
1745
|
-
const errorBody = this.shouldTransformDates ?
|
|
1565
|
+
const errorBody = this.shouldTransformDates ? transformResponse2(responseValue, []) : responseValue;
|
|
1746
1566
|
throw new ErrorEnvelopeError(
|
|
1747
1567
|
`500`,
|
|
1748
1568
|
response,
|
|
1749
1569
|
errorBody,
|
|
1750
|
-
|
|
1570
|
+
getErrorMessage2(errorBody, "An internal server error has occurred."),
|
|
1751
1571
|
e
|
|
1752
1572
|
);
|
|
1753
1573
|
} catch (err) {
|
|
@@ -1771,7 +1591,7 @@ var QueryExecutionClient = class {
|
|
|
1771
1591
|
`${response.status}`,
|
|
1772
1592
|
response,
|
|
1773
1593
|
responseValue,
|
|
1774
|
-
|
|
1594
|
+
getErrorMessage2(
|
|
1775
1595
|
responseValue,
|
|
1776
1596
|
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
1777
1597
|
),
|
|
@@ -1801,7 +1621,7 @@ var queryExecutionClient = /* @__PURE__ */ new QueryExecutionClient(defaultHttpC
|
|
|
1801
1621
|
// packages/client/query/src/lib/error-envelopes/index.ts
|
|
1802
1622
|
import {
|
|
1803
1623
|
ApiClientError as ApiClientError3,
|
|
1804
|
-
ApiGatewayError
|
|
1624
|
+
ApiGatewayError,
|
|
1805
1625
|
ClientRequestError as ClientRequestError4,
|
|
1806
1626
|
InvalidResponseError as InvalidResponseError3,
|
|
1807
1627
|
isApiClientError,
|
|
@@ -1897,16 +1717,24 @@ var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
|
1897
1717
|
TokenType2["SearchPattern"] = "SEARCH_PATTERN";
|
|
1898
1718
|
TokenType2["EntitySelectorPart"] = "ENTITY_SELECTOR_PART";
|
|
1899
1719
|
TokenType2["SavedTableName"] = "SAVED_TABLE_NAME";
|
|
1720
|
+
TokenType2["TabularFileName"] = "TABULAR_FILE_NAME";
|
|
1900
1721
|
TokenType2["ParameterModifier"] = "PARAMETER_MODIFIER";
|
|
1901
1722
|
TokenType2["FieldModifier"] = "FIELD_MODIFIER";
|
|
1902
1723
|
TokenType2["EntityType"] = "ENTITY_TYPE";
|
|
1903
1724
|
TokenType2["EntityAttribute"] = "ENTITY_ATTRIBUTE";
|
|
1904
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";
|
|
1905
1733
|
return TokenType2;
|
|
1906
1734
|
})(TokenType || {});
|
|
1907
1735
|
export {
|
|
1908
1736
|
ApiClientError3 as ApiClientError,
|
|
1909
|
-
|
|
1737
|
+
ApiGatewayError,
|
|
1910
1738
|
ClientRequestError4 as ClientRequestError,
|
|
1911
1739
|
DQLNodeNodeType,
|
|
1912
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
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AbortSignal, HttpClient } from '@dynatrace-sdk/http-client';
|
|
2
|
+
import { ApiClientOptions } from '@dynatrace-sdk/shared-client-utils';
|
|
2
3
|
import { ExecuteRequest } from '../models/execute-request';
|
|
3
4
|
import { QueryPollResponse } from '../models/query-poll-response';
|
|
4
5
|
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
|
*/
|
|
@@ -134,7 +134,7 @@ export declare class QueryExecutionClient {
|
|
|
134
134
|
body: ExecuteRequest;
|
|
135
135
|
/** If set additional data will be available in the metadata section. */ enrich?: string;
|
|
136
136
|
/** 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;
|
|
137
|
-
/** If set, query consumption limit will be enforced. */ enforceQueryConsumptionLimit?: boolean;
|
|
137
|
+
/** (DEPRECATED use body parameter 'enforceQueryConsumptionLimit' instead) If set, query consumption limit will be enforced. */ enforceQueryConsumptionLimit?: boolean;
|
|
138
138
|
abortSignal?: AbortSignal;
|
|
139
139
|
}): Promise<QueryStartResponse>;
|
|
140
140
|
/**
|
|
@@ -18,4 +18,8 @@ export interface AutocompleteRequest {
|
|
|
18
18
|
* Query options enhance query functionality for Dynatrace internal services.
|
|
19
19
|
*/
|
|
20
20
|
queryOptions?: QueryOptions;
|
|
21
|
+
/**
|
|
22
|
+
* Boolean to indicate if the query consumption limit should be enforced
|
|
23
|
+
*/
|
|
24
|
+
enforceQueryConsumptionLimit?: boolean;
|
|
21
25
|
}
|
|
@@ -5,7 +5,7 @@ export interface AutocompleteSuggestionPart {
|
|
|
5
5
|
/**
|
|
6
6
|
* The type of the autocomplete token.
|
|
7
7
|
*/
|
|
8
|
-
type: 'SPACE' | 'LINEBREAK' | 'INDENT' | 'PIPE' | 'DOT' | 'COLON' | 'COMMA' | 'ASSIGNMENT' | 'BRACE_OPEN' | 'BRACE_CLOSE' | 'BRACKET_OPEN' | 'BRACKET_CLOSE' | 'PARENTHESIS_OPEN' | 'PARENTHESIS_CLOSE' | 'QUOTE' | 'SINGLE_QUOTE' | 'SLASH' | 'BOOLEAN_TRUE' | 'BOOLEAN_FALSE' | 'NULL' | 'COMMAND_NAME' | 'PARAMETER_KEY' | 'PARAMETER_VALUE_SCOPE' | 'FUNCTION_NAME' | 'TIMESERIES_AGGREGATION' | 'TIMESERIES_AGGREGATION_EXPRESSION' | 'OPERATOR' | 'SEARCH_OPERATOR' | 'TRAVERSAL_OPERATOR' | 'TRAVERSAL_RELATION_NAME' | 'TRAVERSAL_HOP_COUNT' | 'SIMPLE_IDENTIFIER' | 'DATA_OBJECT' | 'NUMBER' | 'STRING' | 'TIME_UNIT' | 'TIMESTAMP_VALUE' | 'METRIC_KEY' | 'VARIABLE' | 'END_COMMENT' | 'UID_VALUE' | 'PARSE_PATTERN' | 'FIELD_PATTERN' | 'SEARCH_PATTERN' | 'ENTITY_SELECTOR_PART' | 'SAVED_TABLE_NAME' | 'PARAMETER_MODIFIER' | 'FIELD_MODIFIER' | 'ENTITY_TYPE' | 'ENTITY_ATTRIBUTE' | 'SMARTSCAPE_ID_VALUE';
|
|
8
|
+
type: 'SPACE' | 'LINEBREAK' | 'INDENT' | 'PIPE' | 'DOT' | 'COLON' | 'COMMA' | 'ASSIGNMENT' | 'BRACE_OPEN' | 'BRACE_CLOSE' | 'BRACKET_OPEN' | 'BRACKET_CLOSE' | 'PARENTHESIS_OPEN' | 'PARENTHESIS_CLOSE' | 'QUOTE' | 'SINGLE_QUOTE' | 'SLASH' | 'BOOLEAN_TRUE' | 'BOOLEAN_FALSE' | 'NULL' | 'COMMAND_NAME' | 'PARAMETER_KEY' | 'PARAMETER_VALUE_SCOPE' | 'FUNCTION_NAME' | 'TIMESERIES_AGGREGATION' | 'TIMESERIES_AGGREGATION_EXPRESSION' | 'OPERATOR' | 'SEARCH_OPERATOR' | 'TRAVERSAL_OPERATOR' | 'TRAVERSAL_RELATION_NAME' | 'TRAVERSAL_HOP_COUNT' | 'SIMPLE_IDENTIFIER' | 'DATA_OBJECT' | 'NUMBER' | 'STRING' | 'TIME_UNIT' | 'TIMESTAMP_VALUE' | 'METRIC_KEY' | 'VARIABLE' | 'END_COMMENT' | 'UID_VALUE' | 'PARSE_PATTERN' | 'FIELD_PATTERN' | 'SEARCH_PATTERN' | 'ENTITY_SELECTOR_PART' | 'SAVED_TABLE_NAME' | 'TABULAR_FILE_NAME' | 'PARAMETER_MODIFIER' | 'FIELD_MODIFIER' | 'ENTITY_TYPE' | 'ENTITY_ATTRIBUTE' | 'SMARTSCAPE_ID_VALUE' | 'ENUM_STRING' | 'FIELD_PREFIX' | 'BUCKET' | 'SMARTSCAPE_NODE_PATTERN' | 'SMARTSCAPE_EDGE_PATTERN' | 'SMARTSCAPE_NODE_TYPE' | 'SMARTSCAPE_EDGE_TYPE';
|
|
9
9
|
/**
|
|
10
10
|
* The type of the suggestion.
|
|
11
11
|
*/
|