@dynatrace-sdk/client-query 1.0.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +174 -0
  3. package/README.md +54 -0
  4. package/cjs/index.js +1788 -0
  5. package/docs/DOCS.md +2833 -0
  6. package/dynatrace-metadata.json +18 -0
  7. package/esm/index.js +1766 -0
  8. package/package.json +11 -0
  9. package/types/index.d.ts +1 -0
  10. package/types/packages/client/query/src/index.d.ts +1 -0
  11. package/types/packages/client/query/src/lib/apis/index.d.ts +2 -0
  12. package/types/packages/client/query/src/lib/apis/query-assistance-api.d.ts +276 -0
  13. package/types/packages/client/query/src/lib/apis/query-execution-api.d.ts +337 -0
  14. package/types/packages/client/query/src/lib/error-envelopes/api-client-error.d.ts +9 -0
  15. package/types/packages/client/query/src/lib/error-envelopes/client-request-error.d.ts +8 -0
  16. package/types/packages/client/query/src/lib/error-envelopes/error-envelope-error.d.ts +8 -0
  17. package/types/packages/client/query/src/lib/error-envelopes/error-serializer.d.ts +3 -0
  18. package/types/packages/client/query/src/lib/error-envelopes/index.d.ts +3 -0
  19. package/types/packages/client/query/src/lib/error-envelopes/invalid-response-error.d.ts +8 -0
  20. package/types/packages/client/query/src/lib/index.d.ts +3 -0
  21. package/types/packages/client/query/src/lib/models/autocomplete-request.d.ts +26 -0
  22. package/types/packages/client/query/src/lib/models/autocomplete-response.d.ts +28 -0
  23. package/types/packages/client/query/src/lib/models/autocomplete-suggestion-part.d.ts +30 -0
  24. package/types/packages/client/query/src/lib/models/autocomplete-suggestion.d.ts +28 -0
  25. package/types/packages/client/query/src/lib/models/dql-alternative-node.d.ts +18 -0
  26. package/types/packages/client/query/src/lib/models/dql-container-node.d.ts +23 -0
  27. package/types/packages/client/query/src/lib/models/dql-node-node-type.d.ts +14 -0
  28. package/types/packages/client/query/src/lib/models/dql-node.d.ts +29 -0
  29. package/types/packages/client/query/src/lib/models/dql-terminal-node.d.ts +26 -0
  30. package/types/packages/client/query/src/lib/models/error-envelope.d.ts +18 -0
  31. package/types/packages/client/query/src/lib/models/error-response-details.d.ts +50 -0
  32. package/types/packages/client/query/src/lib/models/error-response.d.ts +25 -0
  33. package/types/packages/client/query/src/lib/models/execute-request.d.ts +64 -0
  34. package/types/packages/client/query/src/lib/models/field-type-type.d.ts +21 -0
  35. package/types/packages/client/query/src/lib/models/field-type.d.ts +18 -0
  36. package/types/packages/client/query/src/lib/models/geo-point.d.ts +22 -0
  37. package/types/packages/client/query/src/lib/models/grail-metadata.d.ts +66 -0
  38. package/types/packages/client/query/src/lib/models/index.d.ts +35 -0
  39. package/types/packages/client/query/src/lib/models/metadata-notification.d.ts +45 -0
  40. package/types/packages/client/query/src/lib/models/metadata.d.ts +18 -0
  41. package/types/packages/client/query/src/lib/models/metric-metadata.d.ts +32 -0
  42. package/types/packages/client/query/src/lib/models/parse-request.d.ts +24 -0
  43. package/types/packages/client/query/src/lib/models/position-info.d.ts +27 -0
  44. package/types/packages/client/query/src/lib/models/query-poll-response.d.ts +28 -0
  45. package/types/packages/client/query/src/lib/models/query-result.d.ts +27 -0
  46. package/types/packages/client/query/src/lib/models/query-start-response.d.ts +33 -0
  47. package/types/packages/client/query/src/lib/models/query-state.d.ts +17 -0
  48. package/types/packages/client/query/src/lib/models/ranged-field-types-mappings.d.ts +15 -0
  49. package/types/packages/client/query/src/lib/models/ranged-field-types.d.ts +20 -0
  50. package/types/packages/client/query/src/lib/models/result-record-value.d.ts +13 -0
  51. package/types/packages/client/query/src/lib/models/result-record.d.ts +15 -0
  52. package/types/packages/client/query/src/lib/models/timeframe.d.ts +22 -0
  53. package/types/packages/client/query/src/lib/models/token-position.d.ts +20 -0
  54. package/types/packages/client/query/src/lib/models/token-type.d.ts +48 -0
  55. package/types/packages/client/query/src/lib/models/verify-request.d.ts +24 -0
  56. package/types/packages/client/query/src/lib/models/verify-response.d.ts +23 -0
  57. package/types/packages/client/query/src/lib/utils/url-helpers.d.ts +3 -0
  58. package/types/packages/http-client/src/index.d.ts +2 -0
  59. package/types/packages/http-client/src/lib/platform/abort-controller.d.ts +6 -0
  60. package/types/packages/http-client/src/lib/platform/abort-signal.d.ts +6 -0
  61. package/types/packages/http-client/src/lib/platform/apply-content-type-header.d.ts +2 -0
  62. package/types/packages/http-client/src/lib/platform/base-error.d.ts +5 -0
  63. package/types/packages/http-client/src/lib/platform/binary.d.ts +13 -0
  64. package/types/packages/http-client/src/lib/platform/data-type-error.d.ts +6 -0
  65. package/types/packages/http-client/src/lib/platform/decode-response-body.d.ts +3 -0
  66. package/types/packages/http-client/src/lib/platform/default-status-validator.d.ts +2 -0
  67. package/types/packages/http-client/src/lib/platform/encode-request-body.d.ts +2 -0
  68. package/types/packages/http-client/src/lib/platform/http-client-abort-error.d.ts +7 -0
  69. package/types/packages/http-client/src/lib/platform/http-client-request-error.d.ts +7 -0
  70. package/types/packages/http-client/src/lib/platform/http-client-response-error-serializer.d.ts +1 -0
  71. package/types/packages/http-client/src/lib/platform/http-client-response-error.d.ts +8 -0
  72. package/types/packages/http-client/src/lib/platform/http-client-response.d.ts +10 -0
  73. package/types/packages/http-client/src/lib/platform/http-client.d.ts +5 -0
  74. package/types/packages/http-client/src/lib/platform/index.d.ts +11 -0
  75. package/types/packages/http-client/src/lib/platform/unsupported-operation-error.d.ts +6 -0
  76. package/types/packages/http-client/src/lib/types/abort-controller.d.ts +14 -0
  77. package/types/packages/http-client/src/lib/types/abort-signal.d.ts +15 -0
  78. package/types/packages/http-client/src/lib/types/base-error.d.ts +4 -0
  79. package/types/packages/http-client/src/lib/types/binary.d.ts +15 -0
  80. package/types/packages/http-client/src/lib/types/data-type-error.d.ts +14 -0
  81. package/types/packages/http-client/src/lib/types/data-types.d.ts +36 -0
  82. package/types/packages/http-client/src/lib/types/form-data-request-body.d.ts +83 -0
  83. package/types/packages/http-client/src/lib/types/form-data-response-body.d.ts +15 -0
  84. package/types/packages/http-client/src/lib/types/headers.d.ts +6 -0
  85. package/types/packages/http-client/src/lib/types/http-client-abort-error.d.ts +14 -0
  86. package/types/packages/http-client/src/lib/types/http-client-network-error.d.ts +14 -0
  87. package/types/packages/http-client/src/lib/types/http-client-request-error.d.ts +14 -0
  88. package/types/packages/http-client/src/lib/types/http-client-request-options.d.ts +42 -0
  89. package/types/packages/http-client/src/lib/types/http-client-response-error.d.ts +19 -0
  90. package/types/packages/http-client/src/lib/types/http-client-response.d.ts +33 -0
  91. package/types/packages/http-client/src/lib/types/http-client.d.ts +24 -0
  92. package/types/packages/http-client/src/lib/types/index.d.ts +20 -0
  93. package/types/packages/http-client/src/lib/types/request-body-types.d.ts +26 -0
  94. package/types/packages/http-client/src/lib/types/response-body-types.d.ts +46 -0
  95. package/types/packages/http-client/src/lib/types/status-validator.d.ts +7 -0
  96. package/types/packages/http-client/src/lib/types/unsupported-operation-error.d.ts +14 -0
  97. package/types/packages/platform/error-handlers/src/index.d.ts +2 -0
  98. package/types/packages/platform/error-handlers/src/lib/add-global-error-serializer.d.ts +13 -0
  99. package/types/packages/platform/error-handlers/src/lib/types/common-serialized-error.d.ts +10 -0
  100. package/types/packages/platform/error-handlers/src/lib/types/dt-runtime-error-handlers.d.ts +5 -0
  101. package/types/packages/platform/error-handlers/src/lib/types/error-type.d.ts +9 -0
  102. package/types/packages/platform/error-handlers/src/lib/types/global-dt-runtime-with-error-handlers.d.ts +7 -0
  103. package/types/packages/platform/error-handlers/src/lib/types/global-error-serializer.d.ts +10 -0
  104. package/types/packages/platform/error-handlers/src/lib/types/http-serialized-error.d.ts +11 -0
  105. package/types/packages/platform/error-handlers/src/lib/types/index.d.ts +6 -0
  106. package/types/packages/platform/error-handlers/src/lib/types/serialized-error.d.ts +8 -0
  107. package/types/packages/platform/shared/index.d.ts +1 -0
  108. package/types/packages/platform/shared/utils/get-global-with-dt-runtime.d.ts +1 -0
package/cjs/index.js ADDED
@@ -0,0 +1,1788 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Dynatrace LLC
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ "use strict";
17
+ var __defProp = Object.defineProperty;
18
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
19
+ var __getOwnPropNames = Object.getOwnPropertyNames;
20
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
32
+ };
33
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
+
35
+ // packages/client/query/src/index.ts
36
+ var src_exports = {};
37
+ __export(src_exports, {
38
+ DQLNodeNodeType: () => DQLNodeNodeType,
39
+ FieldTypeType: () => FieldTypeType,
40
+ QueryAssistanceClient: () => QueryAssistanceClient,
41
+ QueryExecutionClient: () => QueryExecutionClient,
42
+ QueryState: () => QueryState,
43
+ TokenType: () => TokenType,
44
+ _AutocompleteRequestTransformation: () => _AutocompleteRequestTransformation,
45
+ _AutocompleteResponseTransformation: () => _AutocompleteResponseTransformation,
46
+ _AutocompleteSuggestionPartTransformation: () => _AutocompleteSuggestionPartTransformation,
47
+ _AutocompleteSuggestionTransformation: () => _AutocompleteSuggestionTransformation,
48
+ _DQLAlternativeNodeTransformation: () => _DQLAlternativeNodeTransformation,
49
+ _DQLContainerNodeTransformation: () => _DQLContainerNodeTransformation,
50
+ _DQLNodeNodeTypeTransformation: () => _DQLNodeNodeTypeTransformation,
51
+ _DQLNodeTransformation: () => _DQLNodeTransformation,
52
+ _DQLTerminalNodeTransformation: () => _DQLTerminalNodeTransformation,
53
+ _ErrorEnvelopeTransformation: () => _ErrorEnvelopeTransformation,
54
+ _ErrorResponseDetailsTransformation: () => _ErrorResponseDetailsTransformation,
55
+ _ErrorResponseTransformation: () => _ErrorResponseTransformation,
56
+ _ExecuteRequestTransformation: () => _ExecuteRequestTransformation,
57
+ _FieldTypeTransformation: () => _FieldTypeTransformation,
58
+ _FieldTypeTypeTransformation: () => _FieldTypeTypeTransformation,
59
+ _GeoPointTransformation: () => _GeoPointTransformation,
60
+ _GrailMetadataTransformation: () => _GrailMetadataTransformation,
61
+ _MetadataNotificationTransformation: () => _MetadataNotificationTransformation,
62
+ _MetadataTransformation: () => _MetadataTransformation,
63
+ _MetricMetadataTransformation: () => _MetricMetadataTransformation,
64
+ _ParseRequestTransformation: () => _ParseRequestTransformation,
65
+ _PositionInfoTransformation: () => _PositionInfoTransformation,
66
+ _QueryPollResponseTransformation: () => _QueryPollResponseTransformation,
67
+ _QueryResultTransformation: () => _QueryResultTransformation,
68
+ _QueryStartResponseTransformation: () => _QueryStartResponseTransformation,
69
+ _QueryStateTransformation: () => _QueryStateTransformation,
70
+ _RangedFieldTypesMappingsTransformation: () => _RangedFieldTypesMappingsTransformation,
71
+ _RangedFieldTypesTransformation: () => _RangedFieldTypesTransformation,
72
+ _ResultRecordTransformation: () => _ResultRecordTransformation,
73
+ _ResultRecordValueTransformation: () => _ResultRecordValueTransformation,
74
+ _TimeframeTransformation: () => _TimeframeTransformation,
75
+ _TokenPositionTransformation: () => _TokenPositionTransformation,
76
+ _TokenTypeTransformation: () => _TokenTypeTransformation,
77
+ _VerifyRequestTransformation: () => _VerifyRequestTransformation,
78
+ _VerifyResponseTransformation: () => _VerifyResponseTransformation,
79
+ isApiClientError: () => isApiClientError,
80
+ isClientRequestError: () => isClientRequestError,
81
+ isErrorEnvelopeError: () => isErrorEnvelopeError,
82
+ queryAssistanceClient: () => queryAssistanceClient,
83
+ queryExecutionClient: () => queryExecutionClient
84
+ });
85
+ module.exports = __toCommonJS(src_exports);
86
+
87
+ // packages/client/query/src/lib/apis/query-assistance-api.ts
88
+ var import_http_client = require("@dynatrace-sdk/http-client");
89
+
90
+ // packages/platform/shared/utils/get-global-with-dt-runtime.ts
91
+ var getGlobalWithDtRuntime = () => typeof globalThis !== "undefined" ? globalThis : window;
92
+
93
+ // packages/platform/error-handlers/src/lib/add-global-error-serializer.ts
94
+ function addGlobalErrorSerializer(serializer) {
95
+ const addGlobalErrorSerializerFunc = getAddGlobalErrorSerializer();
96
+ if (typeof addGlobalErrorSerializerFunc === "function") {
97
+ addGlobalErrorSerializerFunc(serializer);
98
+ } else {
99
+ console.warn("Missing addGlobalErrorSerializer function from sdk-web-runtime.");
100
+ }
101
+ }
102
+ function isGlobalErrorSerializerSupported() {
103
+ return typeof getAddGlobalErrorSerializer() === "function";
104
+ }
105
+ function getAddGlobalErrorSerializer() {
106
+ return getGlobalWithDtRuntime().dtRuntime?.errorHandlers?.addGlobalErrorSerializer;
107
+ }
108
+
109
+ // packages/client/query/src/lib/error-envelopes/api-client-error.ts
110
+ var ApiClientError = class extends Error {
111
+ errorType = "JS Error" /* COMMON */;
112
+ constructor(name, message) {
113
+ super(message);
114
+ this.name = name;
115
+ }
116
+ };
117
+ function isApiClientError(e) {
118
+ return e instanceof ApiClientError;
119
+ }
120
+
121
+ // packages/client/query/src/lib/error-envelopes/client-request-error.ts
122
+ var ClientRequestError = class extends ApiClientError {
123
+ body;
124
+ response;
125
+ constructor(name, response, body, message) {
126
+ super(name, message);
127
+ this.errorType = "Http Error" /* HTTP */;
128
+ this.body = body;
129
+ this.response = response;
130
+ }
131
+ };
132
+ function isClientRequestError(e) {
133
+ return e instanceof ClientRequestError;
134
+ }
135
+
136
+ // packages/client/query/src/lib/error-envelopes/error-envelope-error.ts
137
+ var ErrorEnvelopeError = class extends ClientRequestError {
138
+ };
139
+ function isErrorEnvelopeError(e) {
140
+ return e instanceof ErrorEnvelopeError;
141
+ }
142
+
143
+ // packages/client/query/src/lib/error-envelopes/error-serializer.ts
144
+ var apiClientErrorSerializer = async (error) => {
145
+ if (isClientRequestError(error)) {
146
+ const status = error.response.status;
147
+ const message = error.message;
148
+ return {
149
+ name: error.name,
150
+ status,
151
+ message,
152
+ stack: error.stack,
153
+ type: "Http Error" /* HTTP */
154
+ };
155
+ } else if (isApiClientError(error)) {
156
+ return {
157
+ name: error.name,
158
+ message: error.message,
159
+ stack: error.stack,
160
+ type: "JS Error" /* COMMON */
161
+ };
162
+ }
163
+ };
164
+ var errorSerializerAdded = false;
165
+ function registerGlobalErrorSerializer(serializer) {
166
+ if (!errorSerializerAdded && isGlobalErrorSerializerSupported()) {
167
+ errorSerializerAdded = true;
168
+ addGlobalErrorSerializer(serializer);
169
+ }
170
+ }
171
+
172
+ // packages/client/query/src/lib/error-envelopes/invalid-response-error.ts
173
+ var InvalidResponseError = class extends ApiClientError {
174
+ responseBody;
175
+ expectedType;
176
+ nestedError;
177
+ constructor(name, nestedError, body, expectedType, message) {
178
+ super(
179
+ name,
180
+ message ?? `${name}: Response does not match expected datatype${expectedType ? " " + expectedType : ""}: ${nestedError?.toString() ?? "unable to deserialize"}`
181
+ );
182
+ this.nestedError = nestedError;
183
+ this.responseBody = body;
184
+ this.expectedType = expectedType;
185
+ }
186
+ };
187
+
188
+ // packages/client/query/src/lib/models/autocomplete-request.ts
189
+ var _AutocompleteRequestTransformation;
190
+ ((_AutocompleteRequestTransformation2) => {
191
+ function fromJson(model) {
192
+ const { query, cursorPosition, timezone, locale } = model;
193
+ return {
194
+ query,
195
+ cursorPosition,
196
+ timezone,
197
+ locale
198
+ };
199
+ }
200
+ _AutocompleteRequestTransformation2.fromJson = fromJson;
201
+ function toJson(model) {
202
+ const { query, cursorPosition, timezone, locale } = model;
203
+ return {
204
+ query,
205
+ cursorPosition,
206
+ timezone,
207
+ locale
208
+ };
209
+ }
210
+ _AutocompleteRequestTransformation2.toJson = toJson;
211
+ })(_AutocompleteRequestTransformation || (_AutocompleteRequestTransformation = {}));
212
+
213
+ // packages/client/query/src/lib/models/token-type.ts
214
+ var TokenType = /* @__PURE__ */ ((TokenType4) => {
215
+ TokenType4["Space"] = "SPACE";
216
+ TokenType4["Linebreak"] = "LINEBREAK";
217
+ TokenType4["Indent"] = "INDENT";
218
+ TokenType4["Pipe"] = "PIPE";
219
+ TokenType4["Dot"] = "DOT";
220
+ TokenType4["Colon"] = "COLON";
221
+ TokenType4["Comma"] = "COMMA";
222
+ TokenType4["Assignment"] = "ASSIGNMENT";
223
+ TokenType4["BraceOpen"] = "BRACE_OPEN";
224
+ TokenType4["BraceClose"] = "BRACE_CLOSE";
225
+ TokenType4["BracketOpen"] = "BRACKET_OPEN";
226
+ TokenType4["BracketClose"] = "BRACKET_CLOSE";
227
+ TokenType4["ParenthesisOpen"] = "PARENTHESIS_OPEN";
228
+ TokenType4["ParenthesisClose"] = "PARENTHESIS_CLOSE";
229
+ TokenType4["Quote"] = "QUOTE";
230
+ TokenType4["SingleQuote"] = "SINGLE_QUOTE";
231
+ TokenType4["Slash"] = "SLASH";
232
+ TokenType4["BooleanTrue"] = "BOOLEAN_TRUE";
233
+ TokenType4["BooleanFalse"] = "BOOLEAN_FALSE";
234
+ TokenType4["Null"] = "NULL";
235
+ TokenType4["CommandName"] = "COMMAND_NAME";
236
+ TokenType4["ParameterKey"] = "PARAMETER_KEY";
237
+ TokenType4["ParameterValueScope"] = "PARAMETER_VALUE_SCOPE";
238
+ TokenType4["FunctionName"] = "FUNCTION_NAME";
239
+ TokenType4["TimeseriesAggregation"] = "TIMESERIES_AGGREGATION";
240
+ TokenType4["Operator"] = "OPERATOR";
241
+ TokenType4["TraversalOperator"] = "TRAVERSAL_OPERATOR";
242
+ TokenType4["TraversalRelationName"] = "TRAVERSAL_RELATION_NAME";
243
+ TokenType4["TraversalHopCount"] = "TRAVERSAL_HOP_COUNT";
244
+ TokenType4["SimpleIdentifier"] = "SIMPLE_IDENTIFIER";
245
+ TokenType4["Number"] = "NUMBER";
246
+ TokenType4["String"] = "STRING";
247
+ TokenType4["TimeUnit"] = "TIME_UNIT";
248
+ TokenType4["TimestampValue"] = "TIMESTAMP_VALUE";
249
+ TokenType4["MetricKey"] = "METRIC_KEY";
250
+ TokenType4["Variable"] = "VARIABLE";
251
+ TokenType4["EndComment"] = "END_COMMENT";
252
+ return TokenType4;
253
+ })(TokenType || {});
254
+ var _TokenTypeTransformation;
255
+ ((_TokenTypeTransformation2) => {
256
+ _TokenTypeTransformation2.toJson = (value) => value;
257
+ _TokenTypeTransformation2.fromJson = (value) => value;
258
+ })(_TokenTypeTransformation || (_TokenTypeTransformation = {}));
259
+
260
+ // packages/client/query/src/lib/models/autocomplete-suggestion-part.ts
261
+ var _AutocompleteSuggestionPartTransformation;
262
+ ((_AutocompleteSuggestionPartTransformation2) => {
263
+ function fromJson(model) {
264
+ const { type, info, synopsis, suggestion } = model;
265
+ return {
266
+ type: _TokenTypeTransformation.fromJson(type),
267
+ info,
268
+ synopsis,
269
+ suggestion
270
+ };
271
+ }
272
+ _AutocompleteSuggestionPartTransformation2.fromJson = fromJson;
273
+ function toJson(model) {
274
+ const { type, info, synopsis, suggestion } = model;
275
+ return {
276
+ type: _TokenTypeTransformation.toJson(type),
277
+ info,
278
+ synopsis,
279
+ suggestion
280
+ };
281
+ }
282
+ _AutocompleteSuggestionPartTransformation2.toJson = toJson;
283
+ })(_AutocompleteSuggestionPartTransformation || (_AutocompleteSuggestionPartTransformation = {}));
284
+
285
+ // packages/client/query/src/lib/models/autocomplete-suggestion.ts
286
+ var _AutocompleteSuggestionTransformation;
287
+ ((_AutocompleteSuggestionTransformation2) => {
288
+ function fromJson(model) {
289
+ const { parts, alreadyTypedCharacters, suggestion } = model;
290
+ return {
291
+ parts: parts?.map((innerValue) => _AutocompleteSuggestionPartTransformation.fromJson(innerValue)),
292
+ alreadyTypedCharacters,
293
+ suggestion
294
+ };
295
+ }
296
+ _AutocompleteSuggestionTransformation2.fromJson = fromJson;
297
+ function toJson(model) {
298
+ const { parts, alreadyTypedCharacters, suggestion } = model;
299
+ return {
300
+ parts: parts?.map((innerValue) => _AutocompleteSuggestionPartTransformation.toJson(innerValue)),
301
+ alreadyTypedCharacters,
302
+ suggestion
303
+ };
304
+ }
305
+ _AutocompleteSuggestionTransformation2.toJson = toJson;
306
+ })(_AutocompleteSuggestionTransformation || (_AutocompleteSuggestionTransformation = {}));
307
+
308
+ // packages/client/query/src/lib/models/autocomplete-response.ts
309
+ var _AutocompleteResponseTransformation;
310
+ ((_AutocompleteResponseTransformation2) => {
311
+ function fromJson(model) {
312
+ const { optional, suggestions, suggestedTtlSeconds } = model;
313
+ return {
314
+ optional,
315
+ suggestions: suggestions?.map((innerValue) => _AutocompleteSuggestionTransformation.fromJson(innerValue)),
316
+ suggestedTtlSeconds
317
+ };
318
+ }
319
+ _AutocompleteResponseTransformation2.fromJson = fromJson;
320
+ function toJson(model) {
321
+ const { optional, suggestions, suggestedTtlSeconds } = model;
322
+ return {
323
+ optional,
324
+ suggestions: suggestions?.map((innerValue) => _AutocompleteSuggestionTransformation.toJson(innerValue)),
325
+ suggestedTtlSeconds
326
+ };
327
+ }
328
+ _AutocompleteResponseTransformation2.toJson = toJson;
329
+ })(_AutocompleteResponseTransformation || (_AutocompleteResponseTransformation = {}));
330
+
331
+ // packages/client/query/src/lib/models/dql-alternative-node.ts
332
+ var _DQLAlternativeNodeTransformation;
333
+ ((_DQLAlternativeNodeTransformation2) => {
334
+ function fromJson(model) {
335
+ const { alternatives } = model;
336
+ return {
337
+ ..._DQLNodeTransformation.fromJson(model, false),
338
+ alternatives
339
+ };
340
+ }
341
+ _DQLAlternativeNodeTransformation2.fromJson = fromJson;
342
+ function toJson(model) {
343
+ const { alternatives } = model;
344
+ return {
345
+ ..._DQLNodeTransformation.toJson(model, false),
346
+ alternatives
347
+ };
348
+ }
349
+ _DQLAlternativeNodeTransformation2.toJson = toJson;
350
+ })(_DQLAlternativeNodeTransformation || (_DQLAlternativeNodeTransformation = {}));
351
+
352
+ // packages/client/query/src/lib/models/dql-container-node.ts
353
+ var _DQLContainerNodeTransformation;
354
+ ((_DQLContainerNodeTransformation2) => {
355
+ function fromJson(model) {
356
+ const { type, children } = model;
357
+ return {
358
+ ..._DQLNodeTransformation.fromJson(model, false),
359
+ type,
360
+ children: children !== void 0 && children !== null ? children?.map((innerValue) => _DQLNodeTransformation.fromJson(innerValue)) : void 0
361
+ };
362
+ }
363
+ _DQLContainerNodeTransformation2.fromJson = fromJson;
364
+ function toJson(model) {
365
+ const { type, children } = model;
366
+ return {
367
+ ..._DQLNodeTransformation.toJson(model, false),
368
+ type,
369
+ children: children !== void 0 && children !== null ? children?.map((innerValue) => _DQLNodeTransformation.toJson(innerValue)) : void 0
370
+ };
371
+ }
372
+ _DQLContainerNodeTransformation2.toJson = toJson;
373
+ })(_DQLContainerNodeTransformation || (_DQLContainerNodeTransformation = {}));
374
+
375
+ // packages/client/query/src/lib/models/dql-node-node-type.ts
376
+ var DQLNodeNodeType = /* @__PURE__ */ ((DQLNodeNodeType3) => {
377
+ DQLNodeNodeType3["Terminal"] = "TERMINAL";
378
+ DQLNodeNodeType3["Container"] = "CONTAINER";
379
+ DQLNodeNodeType3["Alternative"] = "ALTERNATIVE";
380
+ return DQLNodeNodeType3;
381
+ })(DQLNodeNodeType || {});
382
+ var _DQLNodeNodeTypeTransformation;
383
+ ((_DQLNodeNodeTypeTransformation2) => {
384
+ _DQLNodeNodeTypeTransformation2.toJson = (value) => value;
385
+ _DQLNodeNodeTypeTransformation2.fromJson = (value) => value;
386
+ })(_DQLNodeNodeTypeTransformation || (_DQLNodeNodeTypeTransformation = {}));
387
+
388
+ // packages/client/query/src/lib/models/dql-terminal-node.ts
389
+ var _DQLTerminalNodeTransformation;
390
+ ((_DQLTerminalNodeTransformation2) => {
391
+ function fromJson(model) {
392
+ const { type, isMandatoryOnUserOrder, canonicalString } = model;
393
+ return {
394
+ ..._DQLNodeTransformation.fromJson(model, false),
395
+ type: type !== void 0 && type !== null ? _TokenTypeTransformation.fromJson(type) : void 0,
396
+ isMandatoryOnUserOrder,
397
+ canonicalString
398
+ };
399
+ }
400
+ _DQLTerminalNodeTransformation2.fromJson = fromJson;
401
+ function toJson(model) {
402
+ const { type, isMandatoryOnUserOrder, canonicalString } = model;
403
+ return {
404
+ ..._DQLNodeTransformation.toJson(model, false),
405
+ type: type !== void 0 && type !== null ? _TokenTypeTransformation.toJson(type) : void 0,
406
+ isMandatoryOnUserOrder,
407
+ canonicalString
408
+ };
409
+ }
410
+ _DQLTerminalNodeTransformation2.toJson = toJson;
411
+ })(_DQLTerminalNodeTransformation || (_DQLTerminalNodeTransformation = {}));
412
+
413
+ // packages/client/query/src/lib/models/position-info.ts
414
+ var _PositionInfoTransformation;
415
+ ((_PositionInfoTransformation2) => {
416
+ function fromJson(model) {
417
+ const { column, index, line } = model;
418
+ return {
419
+ column,
420
+ index,
421
+ line
422
+ };
423
+ }
424
+ _PositionInfoTransformation2.fromJson = fromJson;
425
+ function toJson(model) {
426
+ const { column, index, line } = model;
427
+ return {
428
+ column,
429
+ index,
430
+ line
431
+ };
432
+ }
433
+ _PositionInfoTransformation2.toJson = toJson;
434
+ })(_PositionInfoTransformation || (_PositionInfoTransformation = {}));
435
+
436
+ // packages/client/query/src/lib/models/token-position.ts
437
+ var _TokenPositionTransformation;
438
+ ((_TokenPositionTransformation2) => {
439
+ function fromJson(model) {
440
+ const { start, end } = model;
441
+ return {
442
+ start: _PositionInfoTransformation.fromJson(start),
443
+ end: _PositionInfoTransformation.fromJson(end)
444
+ };
445
+ }
446
+ _TokenPositionTransformation2.fromJson = fromJson;
447
+ function toJson(model) {
448
+ const { start, end } = model;
449
+ return {
450
+ start: _PositionInfoTransformation.toJson(start),
451
+ end: _PositionInfoTransformation.toJson(end)
452
+ };
453
+ }
454
+ _TokenPositionTransformation2.toJson = toJson;
455
+ function fromFormData(formData) {
456
+ const formDataEntries = Object.fromEntries(formData.map((data) => [data.name, data.value]));
457
+ return {
458
+ start: _PositionInfoTransformation.fromJson(JSON.parse(formDataEntries["start"])),
459
+ end: _PositionInfoTransformation.fromJson(JSON.parse(formDataEntries["end"]))
460
+ };
461
+ }
462
+ _TokenPositionTransformation2.fromFormData = fromFormData;
463
+ function toFormData(model) {
464
+ const json = toJson(model);
465
+ const body = [
466
+ { name: "start", type: "json", value: json["start"] },
467
+ { name: "end", type: "json", value: json["end"] }
468
+ ];
469
+ return body;
470
+ }
471
+ _TokenPositionTransformation2.toFormData = toFormData;
472
+ })(_TokenPositionTransformation || (_TokenPositionTransformation = {}));
473
+
474
+ // packages/client/query/src/lib/models/dql-node.ts
475
+ var _DQLNodeTransformation;
476
+ ((_DQLNodeTransformation2) => {
477
+ function isDqlTerminalNode(model) {
478
+ return model["nodeType"] === "TERMINAL";
479
+ }
480
+ _DQLNodeTransformation2.isDqlTerminalNode = isDqlTerminalNode;
481
+ function isDqlContainerNode(model) {
482
+ return model["nodeType"] === "CONTAINER";
483
+ }
484
+ _DQLNodeTransformation2.isDqlContainerNode = isDqlContainerNode;
485
+ function isDqlAlternativeNode(model) {
486
+ return model["nodeType"] === "ALTERNATIVE";
487
+ }
488
+ _DQLNodeTransformation2.isDqlAlternativeNode = isDqlAlternativeNode;
489
+ function fromJson(model, includeChildProps = true) {
490
+ if (includeChildProps) {
491
+ switch (model.nodeType) {
492
+ case "TERMINAL":
493
+ return _DQLTerminalNodeTransformation.fromJson(model);
494
+ case "CONTAINER":
495
+ return _DQLContainerNodeTransformation.fromJson(model);
496
+ case "ALTERNATIVE":
497
+ return _DQLAlternativeNodeTransformation.fromJson(model);
498
+ default:
499
+ return fromJson(model, false);
500
+ }
501
+ }
502
+ const { nodeType, tokenPosition, isOptional } = model;
503
+ return {
504
+ nodeType: _DQLNodeNodeTypeTransformation.fromJson(nodeType),
505
+ tokenPosition: tokenPosition !== void 0 && tokenPosition !== null ? _TokenPositionTransformation.fromJson(tokenPosition) : void 0,
506
+ isOptional
507
+ };
508
+ }
509
+ _DQLNodeTransformation2.fromJson = fromJson;
510
+ function toJson(model, includeChildProps = true) {
511
+ if (includeChildProps) {
512
+ switch (model.nodeType) {
513
+ case "TERMINAL":
514
+ return _DQLTerminalNodeTransformation.toJson(model);
515
+ case "CONTAINER":
516
+ return _DQLContainerNodeTransformation.toJson(model);
517
+ case "ALTERNATIVE":
518
+ return _DQLAlternativeNodeTransformation.toJson(model);
519
+ default:
520
+ return toJson(model, false);
521
+ }
522
+ }
523
+ const { nodeType, tokenPosition, isOptional } = model;
524
+ return {
525
+ nodeType: _DQLNodeNodeTypeTransformation.toJson(nodeType),
526
+ tokenPosition: tokenPosition !== void 0 && tokenPosition !== null ? _TokenPositionTransformation.toJson(tokenPosition) : void 0,
527
+ isOptional
528
+ };
529
+ }
530
+ _DQLNodeTransformation2.toJson = toJson;
531
+ })(_DQLNodeTransformation || (_DQLNodeTransformation = {}));
532
+
533
+ // packages/client/query/src/lib/models/error-response-details.ts
534
+ var _ErrorResponseDetailsTransformation;
535
+ ((_ErrorResponseDetailsTransformation2) => {
536
+ function fromJson(model) {
537
+ const {
538
+ exceptionType,
539
+ syntaxErrorPosition,
540
+ errorType,
541
+ errorMessage,
542
+ arguments: _arguments,
543
+ queryString,
544
+ errorMessageFormatSpecifierTypes,
545
+ errorMessageFormat
546
+ } = model;
547
+ return {
548
+ exceptionType,
549
+ syntaxErrorPosition: syntaxErrorPosition !== void 0 && syntaxErrorPosition !== null ? _TokenPositionTransformation.fromJson(syntaxErrorPosition) : void 0,
550
+ errorType,
551
+ errorMessage,
552
+ arguments: _arguments?.slice(0),
553
+ queryString,
554
+ errorMessageFormatSpecifierTypes: errorMessageFormatSpecifierTypes?.slice(0),
555
+ errorMessageFormat
556
+ };
557
+ }
558
+ _ErrorResponseDetailsTransformation2.fromJson = fromJson;
559
+ function toJson(model) {
560
+ const {
561
+ exceptionType,
562
+ syntaxErrorPosition,
563
+ errorType,
564
+ errorMessage,
565
+ arguments: _arguments,
566
+ queryString,
567
+ errorMessageFormatSpecifierTypes,
568
+ errorMessageFormat
569
+ } = model;
570
+ return {
571
+ exceptionType,
572
+ syntaxErrorPosition: syntaxErrorPosition !== void 0 && syntaxErrorPosition !== null ? _TokenPositionTransformation.toJson(syntaxErrorPosition) : void 0,
573
+ errorType,
574
+ errorMessage,
575
+ arguments: _arguments?.slice(0),
576
+ queryString,
577
+ errorMessageFormatSpecifierTypes: errorMessageFormatSpecifierTypes?.slice(0),
578
+ errorMessageFormat
579
+ };
580
+ }
581
+ _ErrorResponseDetailsTransformation2.toJson = toJson;
582
+ })(_ErrorResponseDetailsTransformation || (_ErrorResponseDetailsTransformation = {}));
583
+
584
+ // packages/client/query/src/lib/models/error-response.ts
585
+ var _ErrorResponseTransformation;
586
+ ((_ErrorResponseTransformation2) => {
587
+ function fromJson(model) {
588
+ const { message, details, code } = model;
589
+ return {
590
+ message,
591
+ details: _ErrorResponseDetailsTransformation.fromJson(details),
592
+ code
593
+ };
594
+ }
595
+ _ErrorResponseTransformation2.fromJson = fromJson;
596
+ function toJson(model) {
597
+ const { message, details, code } = model;
598
+ return {
599
+ message,
600
+ details: _ErrorResponseDetailsTransformation.toJson(details),
601
+ code
602
+ };
603
+ }
604
+ _ErrorResponseTransformation2.toJson = toJson;
605
+ })(_ErrorResponseTransformation || (_ErrorResponseTransformation = {}));
606
+
607
+ // packages/client/query/src/lib/models/error-envelope.ts
608
+ var _ErrorEnvelopeTransformation;
609
+ ((_ErrorEnvelopeTransformation2) => {
610
+ function fromJson(model) {
611
+ const { error } = model;
612
+ return {
613
+ error: _ErrorResponseTransformation.fromJson(error)
614
+ };
615
+ }
616
+ _ErrorEnvelopeTransformation2.fromJson = fromJson;
617
+ function toJson(model) {
618
+ const { error } = model;
619
+ return {
620
+ error: _ErrorResponseTransformation.toJson(error)
621
+ };
622
+ }
623
+ _ErrorEnvelopeTransformation2.toJson = toJson;
624
+ function fromFormData(formData) {
625
+ const formDataEntries = Object.fromEntries(formData.map((data) => [data.name, data.value]));
626
+ return {
627
+ error: _ErrorResponseTransformation.fromJson(JSON.parse(formDataEntries["error"]))
628
+ };
629
+ }
630
+ _ErrorEnvelopeTransformation2.fromFormData = fromFormData;
631
+ function toFormData(model) {
632
+ const json = toJson(model);
633
+ const body = [{ name: "error", type: "json", value: json["error"] }];
634
+ return body;
635
+ }
636
+ _ErrorEnvelopeTransformation2.toFormData = toFormData;
637
+ })(_ErrorEnvelopeTransformation || (_ErrorEnvelopeTransformation = {}));
638
+
639
+ // packages/client/query/src/lib/models/parse-request.ts
640
+ var _ParseRequestTransformation;
641
+ ((_ParseRequestTransformation2) => {
642
+ function fromJson(model) {
643
+ const { query, timezone, locale } = model;
644
+ return {
645
+ query,
646
+ timezone,
647
+ locale
648
+ };
649
+ }
650
+ _ParseRequestTransformation2.fromJson = fromJson;
651
+ function toJson(model) {
652
+ const { query, timezone, locale } = model;
653
+ return {
654
+ query,
655
+ timezone,
656
+ locale
657
+ };
658
+ }
659
+ _ParseRequestTransformation2.toJson = toJson;
660
+ })(_ParseRequestTransformation || (_ParseRequestTransformation = {}));
661
+
662
+ // packages/client/query/src/lib/models/verify-request.ts
663
+ var _VerifyRequestTransformation;
664
+ ((_VerifyRequestTransformation2) => {
665
+ function fromJson(model) {
666
+ const { query, timezone, locale } = model;
667
+ return {
668
+ query,
669
+ timezone,
670
+ locale
671
+ };
672
+ }
673
+ _VerifyRequestTransformation2.fromJson = fromJson;
674
+ function toJson(model) {
675
+ const { query, timezone, locale } = model;
676
+ return {
677
+ query,
678
+ timezone,
679
+ locale
680
+ };
681
+ }
682
+ _VerifyRequestTransformation2.toJson = toJson;
683
+ })(_VerifyRequestTransformation || (_VerifyRequestTransformation = {}));
684
+
685
+ // packages/client/query/src/lib/models/metadata-notification.ts
686
+ var _MetadataNotificationTransformation;
687
+ ((_MetadataNotificationTransformation2) => {
688
+ function fromJson(model) {
689
+ const {
690
+ severity,
691
+ messageFormat,
692
+ syntaxPosition,
693
+ messageFormatSpecifierTypes,
694
+ arguments: _arguments,
695
+ notificationType,
696
+ message
697
+ } = model;
698
+ return {
699
+ severity,
700
+ messageFormat,
701
+ syntaxPosition: syntaxPosition !== void 0 && syntaxPosition !== null ? _TokenPositionTransformation.fromJson(syntaxPosition) : void 0,
702
+ messageFormatSpecifierTypes: messageFormatSpecifierTypes !== void 0 && messageFormatSpecifierTypes !== null ? messageFormatSpecifierTypes?.slice(0) : void 0,
703
+ arguments: _arguments !== void 0 && _arguments !== null ? _arguments?.slice(0) : void 0,
704
+ notificationType,
705
+ message
706
+ };
707
+ }
708
+ _MetadataNotificationTransformation2.fromJson = fromJson;
709
+ function toJson(model) {
710
+ const {
711
+ severity,
712
+ messageFormat,
713
+ syntaxPosition,
714
+ messageFormatSpecifierTypes,
715
+ arguments: _arguments,
716
+ notificationType,
717
+ message
718
+ } = model;
719
+ return {
720
+ severity,
721
+ messageFormat,
722
+ syntaxPosition: syntaxPosition !== void 0 && syntaxPosition !== null ? _TokenPositionTransformation.toJson(syntaxPosition) : void 0,
723
+ messageFormatSpecifierTypes: messageFormatSpecifierTypes !== void 0 && messageFormatSpecifierTypes !== null ? messageFormatSpecifierTypes?.slice(0) : void 0,
724
+ arguments: _arguments !== void 0 && _arguments !== null ? _arguments?.slice(0) : void 0,
725
+ notificationType,
726
+ message
727
+ };
728
+ }
729
+ _MetadataNotificationTransformation2.toJson = toJson;
730
+ })(_MetadataNotificationTransformation || (_MetadataNotificationTransformation = {}));
731
+
732
+ // packages/client/query/src/lib/models/verify-response.ts
733
+ var _VerifyResponseTransformation;
734
+ ((_VerifyResponseTransformation2) => {
735
+ function fromJson(model) {
736
+ const { valid, notifications } = model;
737
+ return {
738
+ valid,
739
+ notifications: notifications !== void 0 && notifications !== null ? notifications?.map((innerValue) => _MetadataNotificationTransformation.fromJson(innerValue)) : void 0
740
+ };
741
+ }
742
+ _VerifyResponseTransformation2.fromJson = fromJson;
743
+ function toJson(model) {
744
+ const { valid, notifications } = model;
745
+ return {
746
+ valid,
747
+ notifications: notifications !== void 0 && notifications !== null ? notifications?.map((innerValue) => _MetadataNotificationTransformation.toJson(innerValue)) : void 0
748
+ };
749
+ }
750
+ _VerifyResponseTransformation2.toJson = toJson;
751
+ })(_VerifyResponseTransformation || (_VerifyResponseTransformation = {}));
752
+
753
+ // packages/client/query/src/lib/apis/query-assistance-api.ts
754
+ var QueryAssistanceClient = class {
755
+ httpClient;
756
+ constructor(httpClientImplementation) {
757
+ this.httpClient = httpClientImplementation;
758
+ registerGlobalErrorSerializer(apiClientErrorSerializer);
759
+ }
760
+ async queryVerify(config) {
761
+ if (!config) {
762
+ throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
763
+ }
764
+ const encodedBody = _VerifyRequestTransformation.toJson(config.body);
765
+ const headerParameters = {
766
+ ...config.authorization !== void 0 && { Authorization: String(config.authorization) }
767
+ };
768
+ const response = await this.httpClient.send({
769
+ url: `/platform/storage/query/v1/query:verify`,
770
+ method: "POST",
771
+ requestBodyType: "json",
772
+ body: encodedBody,
773
+ headers: {
774
+ "Content-Type": "application/json",
775
+ Accept: "application/json",
776
+ ...headerParameters
777
+ },
778
+ abortSignal: config.abortSignal,
779
+ statusValidator: (status) => {
780
+ if (200 <= status && status < 300) {
781
+ return true;
782
+ }
783
+ return [400, 500].includes(status);
784
+ }
785
+ });
786
+ switch (response.status) {
787
+ case 400: {
788
+ const responseValue = await response.body("json");
789
+ try {
790
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
791
+ throw new ErrorEnvelopeError("400", response, errorBody, "The supplied request is wrong.");
792
+ } catch (err) {
793
+ if (err instanceof ErrorEnvelopeError) {
794
+ throw err;
795
+ }
796
+ throw new InvalidResponseError(
797
+ `QueryAssistanceClient.query:verify:400`,
798
+ err,
799
+ responseValue,
800
+ "ErrorEnvelope",
801
+ void 0
802
+ );
803
+ }
804
+ }
805
+ case 500: {
806
+ const responseValue = await response.body("json");
807
+ try {
808
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
809
+ throw new ErrorEnvelopeError("500", response, errorBody, "An internal server error has occurred.");
810
+ } catch (err) {
811
+ if (err instanceof ErrorEnvelopeError) {
812
+ throw err;
813
+ }
814
+ throw new InvalidResponseError(
815
+ `QueryAssistanceClient.query:verify:500`,
816
+ err,
817
+ responseValue,
818
+ "ErrorEnvelope",
819
+ void 0
820
+ );
821
+ }
822
+ }
823
+ case 200: {
824
+ const responseValue = await response.body("json");
825
+ try {
826
+ return _VerifyResponseTransformation.fromJson(responseValue);
827
+ } catch (err) {
828
+ throw new InvalidResponseError(
829
+ `QueryAssistanceClient.query:verify:${response.status}`,
830
+ err,
831
+ responseValue,
832
+ void 0,
833
+ void 0
834
+ );
835
+ }
836
+ }
837
+ default: {
838
+ const responseValue = await response.body("text").catch();
839
+ throw new ClientRequestError(
840
+ `${response.status}`,
841
+ response,
842
+ responseValue,
843
+ `Unexpected api response: code=${response.status} body="${responseValue}"`
844
+ );
845
+ }
846
+ }
847
+ }
848
+ async queryParse(config) {
849
+ if (!config) {
850
+ throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
851
+ }
852
+ const encodedBody = _ParseRequestTransformation.toJson(config.body);
853
+ const headerParameters = {
854
+ ...config.authorization !== void 0 && { Authorization: String(config.authorization) }
855
+ };
856
+ const response = await this.httpClient.send({
857
+ url: `/platform/storage/query/v1/query:parse`,
858
+ method: "POST",
859
+ requestBodyType: "json",
860
+ body: encodedBody,
861
+ headers: {
862
+ "Content-Type": "application/json",
863
+ Accept: "application/json",
864
+ ...headerParameters
865
+ },
866
+ abortSignal: config.abortSignal,
867
+ statusValidator: (status) => {
868
+ if (200 <= status && status < 300) {
869
+ return true;
870
+ }
871
+ return [400, 500].includes(status);
872
+ }
873
+ });
874
+ switch (response.status) {
875
+ case 400: {
876
+ const responseValue = await response.body("json");
877
+ try {
878
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
879
+ throw new ErrorEnvelopeError(
880
+ "400",
881
+ response,
882
+ errorBody,
883
+ "The supplied request is wrong. Either the query itself or other parameters are wrong."
884
+ );
885
+ } catch (err) {
886
+ if (err instanceof ErrorEnvelopeError) {
887
+ throw err;
888
+ }
889
+ throw new InvalidResponseError(
890
+ `QueryAssistanceClient.query:parse:400`,
891
+ err,
892
+ responseValue,
893
+ "ErrorEnvelope",
894
+ void 0
895
+ );
896
+ }
897
+ }
898
+ case 500: {
899
+ const responseValue = await response.body("json");
900
+ try {
901
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
902
+ throw new ErrorEnvelopeError("500", response, errorBody, "An internal server error has occurred.");
903
+ } catch (err) {
904
+ if (err instanceof ErrorEnvelopeError) {
905
+ throw err;
906
+ }
907
+ throw new InvalidResponseError(
908
+ `QueryAssistanceClient.query:parse:500`,
909
+ err,
910
+ responseValue,
911
+ "ErrorEnvelope",
912
+ void 0
913
+ );
914
+ }
915
+ }
916
+ case 200: {
917
+ const responseValue = await response.body("json");
918
+ try {
919
+ return _DQLNodeTransformation.fromJson(responseValue);
920
+ } catch (err) {
921
+ throw new InvalidResponseError(
922
+ `QueryAssistanceClient.query:parse:${response.status}`,
923
+ err,
924
+ responseValue,
925
+ void 0,
926
+ void 0
927
+ );
928
+ }
929
+ }
930
+ default: {
931
+ const responseValue = await response.body("text").catch();
932
+ throw new ClientRequestError(
933
+ `${response.status}`,
934
+ response,
935
+ responseValue,
936
+ `Unexpected api response: code=${response.status} body="${responseValue}"`
937
+ );
938
+ }
939
+ }
940
+ }
941
+ async queryAutocomplete(config) {
942
+ if (!config) {
943
+ throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
944
+ }
945
+ const encodedBody = _AutocompleteRequestTransformation.toJson(config.body);
946
+ const headerParameters = {
947
+ ...config.authorization !== void 0 && { Authorization: String(config.authorization) }
948
+ };
949
+ const response = await this.httpClient.send({
950
+ url: `/platform/storage/query/v1/query:autocomplete`,
951
+ method: "POST",
952
+ requestBodyType: "json",
953
+ body: encodedBody,
954
+ headers: {
955
+ "Content-Type": "application/json",
956
+ Accept: "application/json",
957
+ ...headerParameters
958
+ },
959
+ abortSignal: config.abortSignal,
960
+ statusValidator: (status) => {
961
+ if (200 <= status && status < 300) {
962
+ return true;
963
+ }
964
+ return [400, 500].includes(status);
965
+ }
966
+ });
967
+ switch (response.status) {
968
+ case 400: {
969
+ const responseValue = await response.body("json");
970
+ try {
971
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
972
+ throw new ErrorEnvelopeError(
973
+ "400",
974
+ response,
975
+ errorBody,
976
+ "The supplied request is wrong. Either the query itself or other parameters are wrong."
977
+ );
978
+ } catch (err) {
979
+ if (err instanceof ErrorEnvelopeError) {
980
+ throw err;
981
+ }
982
+ throw new InvalidResponseError(
983
+ `QueryAssistanceClient.query:autocomplete:400`,
984
+ err,
985
+ responseValue,
986
+ "ErrorEnvelope",
987
+ void 0
988
+ );
989
+ }
990
+ }
991
+ case 500: {
992
+ const responseValue = await response.body("json");
993
+ try {
994
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
995
+ throw new ErrorEnvelopeError("500", response, errorBody, "An internal server error has occurred.");
996
+ } catch (err) {
997
+ if (err instanceof ErrorEnvelopeError) {
998
+ throw err;
999
+ }
1000
+ throw new InvalidResponseError(
1001
+ `QueryAssistanceClient.query:autocomplete:500`,
1002
+ err,
1003
+ responseValue,
1004
+ "ErrorEnvelope",
1005
+ void 0
1006
+ );
1007
+ }
1008
+ }
1009
+ case 200: {
1010
+ const responseValue = await response.body("json");
1011
+ try {
1012
+ return _AutocompleteResponseTransformation.fromJson(responseValue);
1013
+ } catch (err) {
1014
+ throw new InvalidResponseError(
1015
+ `QueryAssistanceClient.query:autocomplete:${response.status}`,
1016
+ err,
1017
+ responseValue,
1018
+ void 0,
1019
+ void 0
1020
+ );
1021
+ }
1022
+ }
1023
+ default: {
1024
+ const responseValue = await response.body("text").catch();
1025
+ throw new ClientRequestError(
1026
+ `${response.status}`,
1027
+ response,
1028
+ responseValue,
1029
+ `Unexpected api response: code=${response.status} body="${responseValue}"`
1030
+ );
1031
+ }
1032
+ }
1033
+ }
1034
+ };
1035
+ var queryAssistanceClient = /* @__PURE__ */ new QueryAssistanceClient(import_http_client.httpClient);
1036
+
1037
+ // packages/client/query/src/lib/apis/query-execution-api.ts
1038
+ var import_http_client2 = require("@dynatrace-sdk/http-client");
1039
+
1040
+ // packages/client/query/src/lib/models/execute-request.ts
1041
+ var _ExecuteRequestTransformation;
1042
+ ((_ExecuteRequestTransformation2) => {
1043
+ function fromJson(model) {
1044
+ const {
1045
+ query,
1046
+ defaultTimeframeStart,
1047
+ defaultTimeframeEnd,
1048
+ timezone,
1049
+ locale,
1050
+ maxResultRecords,
1051
+ fetchTimeoutSeconds,
1052
+ requestTimeoutMilliseconds,
1053
+ enablePreview,
1054
+ defaultSamplingRatio,
1055
+ defaultScanLimitGbytes
1056
+ } = model;
1057
+ return {
1058
+ query,
1059
+ defaultTimeframeStart,
1060
+ defaultTimeframeEnd,
1061
+ timezone,
1062
+ locale,
1063
+ maxResultRecords,
1064
+ fetchTimeoutSeconds,
1065
+ requestTimeoutMilliseconds,
1066
+ enablePreview,
1067
+ defaultSamplingRatio,
1068
+ defaultScanLimitGbytes
1069
+ };
1070
+ }
1071
+ _ExecuteRequestTransformation2.fromJson = fromJson;
1072
+ function toJson(model) {
1073
+ const {
1074
+ query,
1075
+ defaultTimeframeStart,
1076
+ defaultTimeframeEnd,
1077
+ timezone,
1078
+ locale,
1079
+ maxResultRecords,
1080
+ fetchTimeoutSeconds,
1081
+ requestTimeoutMilliseconds,
1082
+ enablePreview,
1083
+ defaultSamplingRatio,
1084
+ defaultScanLimitGbytes
1085
+ } = model;
1086
+ return {
1087
+ query,
1088
+ defaultTimeframeStart,
1089
+ defaultTimeframeEnd,
1090
+ timezone,
1091
+ locale,
1092
+ maxResultRecords,
1093
+ fetchTimeoutSeconds,
1094
+ requestTimeoutMilliseconds,
1095
+ enablePreview,
1096
+ defaultSamplingRatio,
1097
+ defaultScanLimitGbytes
1098
+ };
1099
+ }
1100
+ _ExecuteRequestTransformation2.toJson = toJson;
1101
+ })(_ExecuteRequestTransformation || (_ExecuteRequestTransformation = {}));
1102
+
1103
+ // packages/client/query/src/lib/models/timeframe.ts
1104
+ var _TimeframeTransformation;
1105
+ ((_TimeframeTransformation2) => {
1106
+ function fromJson(model) {
1107
+ const { start, end } = model;
1108
+ return {
1109
+ start: start !== void 0 && start !== null ? new Date(start) : void 0,
1110
+ end: end !== void 0 && end !== null ? new Date(end) : void 0
1111
+ };
1112
+ }
1113
+ _TimeframeTransformation2.fromJson = fromJson;
1114
+ function toJson(model) {
1115
+ const { start, end } = model;
1116
+ return {
1117
+ start: start !== void 0 && start !== null ? start.toISOString() : void 0,
1118
+ end: end !== void 0 && end !== null ? end.toISOString() : void 0
1119
+ };
1120
+ }
1121
+ _TimeframeTransformation2.toJson = toJson;
1122
+ })(_TimeframeTransformation || (_TimeframeTransformation = {}));
1123
+
1124
+ // packages/client/query/src/lib/models/grail-metadata.ts
1125
+ var _GrailMetadataTransformation;
1126
+ ((_GrailMetadataTransformation2) => {
1127
+ function fromJson(model) {
1128
+ const {
1129
+ canonicalQuery,
1130
+ timezone,
1131
+ query,
1132
+ scannedRecords,
1133
+ dqlVersion,
1134
+ scannedBytes,
1135
+ analysisTimeframe,
1136
+ locale,
1137
+ executionTimeMilliseconds,
1138
+ notifications,
1139
+ queryId
1140
+ } = model;
1141
+ return {
1142
+ canonicalQuery,
1143
+ timezone,
1144
+ query,
1145
+ scannedRecords,
1146
+ dqlVersion,
1147
+ scannedBytes,
1148
+ analysisTimeframe: analysisTimeframe !== void 0 && analysisTimeframe !== null ? _TimeframeTransformation.fromJson(analysisTimeframe) : void 0,
1149
+ locale,
1150
+ executionTimeMilliseconds,
1151
+ notifications: notifications !== void 0 && notifications !== null ? notifications?.map((innerValue) => _MetadataNotificationTransformation.fromJson(innerValue)) : void 0,
1152
+ queryId
1153
+ };
1154
+ }
1155
+ _GrailMetadataTransformation2.fromJson = fromJson;
1156
+ function toJson(model) {
1157
+ const {
1158
+ canonicalQuery,
1159
+ timezone,
1160
+ query,
1161
+ scannedRecords,
1162
+ dqlVersion,
1163
+ scannedBytes,
1164
+ analysisTimeframe,
1165
+ locale,
1166
+ executionTimeMilliseconds,
1167
+ notifications,
1168
+ queryId
1169
+ } = model;
1170
+ return {
1171
+ canonicalQuery,
1172
+ timezone,
1173
+ query,
1174
+ scannedRecords,
1175
+ dqlVersion,
1176
+ scannedBytes,
1177
+ analysisTimeframe: analysisTimeframe !== void 0 && analysisTimeframe !== null ? _TimeframeTransformation.toJson(analysisTimeframe) : void 0,
1178
+ locale,
1179
+ executionTimeMilliseconds,
1180
+ notifications: notifications !== void 0 && notifications !== null ? notifications?.map((innerValue) => _MetadataNotificationTransformation.toJson(innerValue)) : void 0,
1181
+ queryId
1182
+ };
1183
+ }
1184
+ _GrailMetadataTransformation2.toJson = toJson;
1185
+ })(_GrailMetadataTransformation || (_GrailMetadataTransformation = {}));
1186
+
1187
+ // packages/client/query/src/lib/models/metric-metadata.ts
1188
+ var _MetricMetadataTransformation;
1189
+ ((_MetricMetadataTransformation2) => {
1190
+ function fromJson(model) {
1191
+ const { "metric.key": metricKey, displayName, description, unit } = model;
1192
+ return {
1193
+ "metric.key": metricKey,
1194
+ displayName,
1195
+ description,
1196
+ unit
1197
+ };
1198
+ }
1199
+ _MetricMetadataTransformation2.fromJson = fromJson;
1200
+ function toJson(model) {
1201
+ const { "metric.key": metricKey, displayName, description, unit } = model;
1202
+ return {
1203
+ "metric.key": metricKey,
1204
+ displayName,
1205
+ description,
1206
+ unit
1207
+ };
1208
+ }
1209
+ _MetricMetadataTransformation2.toJson = toJson;
1210
+ })(_MetricMetadataTransformation || (_MetricMetadataTransformation = {}));
1211
+
1212
+ // packages/client/query/src/lib/models/metadata.ts
1213
+ var _MetadataTransformation;
1214
+ ((_MetadataTransformation2) => {
1215
+ function fromJson(model) {
1216
+ const { grail, metrics } = model;
1217
+ return {
1218
+ grail: grail !== void 0 && grail !== null ? _GrailMetadataTransformation.fromJson(grail) : void 0,
1219
+ metrics: metrics !== void 0 && metrics !== null ? metrics?.map((innerValue) => _MetricMetadataTransformation.fromJson(innerValue)) : void 0
1220
+ };
1221
+ }
1222
+ _MetadataTransformation2.fromJson = fromJson;
1223
+ function toJson(model) {
1224
+ const { grail, metrics } = model;
1225
+ return {
1226
+ grail: grail !== void 0 && grail !== null ? _GrailMetadataTransformation.toJson(grail) : void 0,
1227
+ metrics: metrics !== void 0 && metrics !== null ? metrics?.map((innerValue) => _MetricMetadataTransformation.toJson(innerValue)) : void 0
1228
+ };
1229
+ }
1230
+ _MetadataTransformation2.toJson = toJson;
1231
+ })(_MetadataTransformation || (_MetadataTransformation = {}));
1232
+
1233
+ // packages/client/query/src/lib/models/field-type-type.ts
1234
+ var FieldTypeType = /* @__PURE__ */ ((FieldTypeType3) => {
1235
+ FieldTypeType3["Boolean"] = "boolean";
1236
+ FieldTypeType3["String"] = "string";
1237
+ FieldTypeType3["Double"] = "double";
1238
+ FieldTypeType3["Long"] = "long";
1239
+ FieldTypeType3["Timestamp"] = "timestamp";
1240
+ FieldTypeType3["Timeframe"] = "timeframe";
1241
+ FieldTypeType3["Duration"] = "duration";
1242
+ FieldTypeType3["Binary"] = "binary";
1243
+ FieldTypeType3["IpAddress"] = "ip_address";
1244
+ FieldTypeType3["GeoPoint"] = "geo_point";
1245
+ FieldTypeType3["Array"] = "array";
1246
+ FieldTypeType3["Record"] = "record";
1247
+ FieldTypeType3["Undefined"] = "undefined";
1248
+ return FieldTypeType3;
1249
+ })(FieldTypeType || {});
1250
+ var _FieldTypeTypeTransformation;
1251
+ ((_FieldTypeTypeTransformation2) => {
1252
+ _FieldTypeTypeTransformation2.toJson = (value) => value;
1253
+ _FieldTypeTypeTransformation2.fromJson = (value) => value;
1254
+ })(_FieldTypeTypeTransformation || (_FieldTypeTypeTransformation = {}));
1255
+
1256
+ // packages/client/query/src/lib/models/field-type.ts
1257
+ var _FieldTypeTransformation;
1258
+ ((_FieldTypeTransformation2) => {
1259
+ function fromJson(model) {
1260
+ const { type, types } = model;
1261
+ return {
1262
+ type: _FieldTypeTypeTransformation.fromJson(type),
1263
+ types: types !== void 0 && types !== null ? types?.map((innerValue) => _RangedFieldTypesTransformation.fromJson(innerValue)) : void 0
1264
+ };
1265
+ }
1266
+ _FieldTypeTransformation2.fromJson = fromJson;
1267
+ function toJson(model) {
1268
+ const { type, types } = model;
1269
+ return {
1270
+ type: _FieldTypeTypeTransformation.toJson(type),
1271
+ types: types !== void 0 && types !== null ? types?.map((innerValue) => _RangedFieldTypesTransformation.toJson(innerValue)) : void 0
1272
+ };
1273
+ }
1274
+ _FieldTypeTransformation2.toJson = toJson;
1275
+ })(_FieldTypeTransformation || (_FieldTypeTransformation = {}));
1276
+
1277
+ // packages/client/query/src/lib/models/ranged-field-types-mappings.ts
1278
+ var _RangedFieldTypesMappingsTransformation;
1279
+ ((_RangedFieldTypesMappingsTransformation2) => {
1280
+ function fromJson(model) {
1281
+ const additionalProps = model;
1282
+ return {
1283
+ ...Object.fromEntries(
1284
+ Object.entries(additionalProps).map(([propName, value]) => [
1285
+ propName,
1286
+ value !== void 0 && value !== null ? _FieldTypeTransformation.fromJson(value) : void 0
1287
+ ])
1288
+ )
1289
+ };
1290
+ }
1291
+ _RangedFieldTypesMappingsTransformation2.fromJson = fromJson;
1292
+ function toJson(model) {
1293
+ const additionalProps = model;
1294
+ return {
1295
+ ...Object.fromEntries(
1296
+ Object.entries(additionalProps).map(([propName, value]) => [
1297
+ propName,
1298
+ value !== void 0 && value !== null ? _FieldTypeTransformation.toJson(value) : void 0
1299
+ ])
1300
+ )
1301
+ };
1302
+ }
1303
+ _RangedFieldTypesMappingsTransformation2.toJson = toJson;
1304
+ })(_RangedFieldTypesMappingsTransformation || (_RangedFieldTypesMappingsTransformation = {}));
1305
+
1306
+ // packages/client/query/src/lib/models/ranged-field-types.ts
1307
+ var _RangedFieldTypesTransformation;
1308
+ ((_RangedFieldTypesTransformation2) => {
1309
+ function fromJson(model) {
1310
+ const { mappings, indexRange } = model;
1311
+ return {
1312
+ mappings: _RangedFieldTypesMappingsTransformation.fromJson(mappings),
1313
+ indexRange: indexRange !== void 0 && indexRange !== null ? indexRange?.slice(0) : void 0
1314
+ };
1315
+ }
1316
+ _RangedFieldTypesTransformation2.fromJson = fromJson;
1317
+ function toJson(model) {
1318
+ const { mappings, indexRange } = model;
1319
+ return {
1320
+ mappings: _RangedFieldTypesMappingsTransformation.toJson(mappings),
1321
+ indexRange: indexRange !== void 0 && indexRange !== null ? indexRange?.slice(0) : void 0
1322
+ };
1323
+ }
1324
+ _RangedFieldTypesTransformation2.toJson = toJson;
1325
+ })(_RangedFieldTypesTransformation || (_RangedFieldTypesTransformation = {}));
1326
+
1327
+ // packages/client/query/src/lib/models/result-record-value.ts
1328
+ var _ResultRecordValueTransformation;
1329
+ ((_ResultRecordValueTransformation2) => {
1330
+ function fromJson(model) {
1331
+ return model;
1332
+ }
1333
+ _ResultRecordValueTransformation2.fromJson = fromJson;
1334
+ function toJson(model) {
1335
+ return model;
1336
+ }
1337
+ _ResultRecordValueTransformation2.toJson = toJson;
1338
+ })(_ResultRecordValueTransformation || (_ResultRecordValueTransformation = {}));
1339
+
1340
+ // packages/client/query/src/lib/models/result-record.ts
1341
+ var _ResultRecordTransformation;
1342
+ ((_ResultRecordTransformation2) => {
1343
+ function fromJson(model) {
1344
+ if (model === null) {
1345
+ return null;
1346
+ }
1347
+ const additionalProps = model;
1348
+ return {
1349
+ ...Object.fromEntries(
1350
+ Object.entries(additionalProps).map(([propName, value]) => [
1351
+ propName,
1352
+ value !== void 0 && value !== null ? _ResultRecordValueTransformation.fromJson(value) : void 0
1353
+ ])
1354
+ )
1355
+ };
1356
+ }
1357
+ _ResultRecordTransformation2.fromJson = fromJson;
1358
+ function toJson(model) {
1359
+ if (model === null) {
1360
+ return null;
1361
+ }
1362
+ const additionalProps = model;
1363
+ return {
1364
+ ...Object.fromEntries(
1365
+ Object.entries(additionalProps).map(([propName, value]) => [
1366
+ propName,
1367
+ value !== void 0 && value !== null ? _ResultRecordValueTransformation.toJson(value) : void 0
1368
+ ])
1369
+ )
1370
+ };
1371
+ }
1372
+ _ResultRecordTransformation2.toJson = toJson;
1373
+ })(_ResultRecordTransformation || (_ResultRecordTransformation = {}));
1374
+
1375
+ // packages/client/query/src/lib/models/query-result.ts
1376
+ var _QueryResultTransformation;
1377
+ ((_QueryResultTransformation2) => {
1378
+ function fromJson(model) {
1379
+ const { records, metadata, types } = model;
1380
+ return {
1381
+ records: records?.map((innerValue) => _ResultRecordTransformation.fromJson(innerValue)),
1382
+ metadata: _MetadataTransformation.fromJson(metadata),
1383
+ types: types?.map((innerValue) => _RangedFieldTypesTransformation.fromJson(innerValue))
1384
+ };
1385
+ }
1386
+ _QueryResultTransformation2.fromJson = fromJson;
1387
+ function toJson(model) {
1388
+ const { records, metadata, types } = model;
1389
+ return {
1390
+ records: records?.map((innerValue) => _ResultRecordTransformation.toJson(innerValue)),
1391
+ metadata: _MetadataTransformation.toJson(metadata),
1392
+ types: types?.map((innerValue) => _RangedFieldTypesTransformation.toJson(innerValue))
1393
+ };
1394
+ }
1395
+ _QueryResultTransformation2.toJson = toJson;
1396
+ })(_QueryResultTransformation || (_QueryResultTransformation = {}));
1397
+
1398
+ // packages/client/query/src/lib/models/query-state.ts
1399
+ var QueryState = /* @__PURE__ */ ((QueryState4) => {
1400
+ QueryState4["NotStarted"] = "NOT_STARTED";
1401
+ QueryState4["Running"] = "RUNNING";
1402
+ QueryState4["Succeeded"] = "SUCCEEDED";
1403
+ QueryState4["ResultGone"] = "RESULT_GONE";
1404
+ QueryState4["Cancelled"] = "CANCELLED";
1405
+ QueryState4["Failed"] = "FAILED";
1406
+ return QueryState4;
1407
+ })(QueryState || {});
1408
+ var _QueryStateTransformation;
1409
+ ((_QueryStateTransformation2) => {
1410
+ _QueryStateTransformation2.toJson = (value) => value;
1411
+ _QueryStateTransformation2.fromJson = (value) => value;
1412
+ })(_QueryStateTransformation || (_QueryStateTransformation = {}));
1413
+
1414
+ // packages/client/query/src/lib/models/query-poll-response.ts
1415
+ var _QueryPollResponseTransformation;
1416
+ ((_QueryPollResponseTransformation2) => {
1417
+ function fromJson(model) {
1418
+ const { result, ttlSeconds, progress, state } = model;
1419
+ return {
1420
+ result: result !== void 0 && result !== null ? _QueryResultTransformation.fromJson(result) : void 0,
1421
+ ttlSeconds,
1422
+ progress,
1423
+ state: _QueryStateTransformation.fromJson(state)
1424
+ };
1425
+ }
1426
+ _QueryPollResponseTransformation2.fromJson = fromJson;
1427
+ function toJson(model) {
1428
+ const { result, ttlSeconds, progress, state } = model;
1429
+ return {
1430
+ result: result !== void 0 && result !== null ? _QueryResultTransformation.toJson(result) : void 0,
1431
+ ttlSeconds,
1432
+ progress,
1433
+ state: _QueryStateTransformation.toJson(state)
1434
+ };
1435
+ }
1436
+ _QueryPollResponseTransformation2.toJson = toJson;
1437
+ })(_QueryPollResponseTransformation || (_QueryPollResponseTransformation = {}));
1438
+
1439
+ // packages/client/query/src/lib/models/query-start-response.ts
1440
+ var _QueryStartResponseTransformation;
1441
+ ((_QueryStartResponseTransformation2) => {
1442
+ function fromJson(model) {
1443
+ const { result, ttlSeconds, progress, requestToken, state } = model;
1444
+ return {
1445
+ result: result !== void 0 && result !== null ? _QueryResultTransformation.fromJson(result) : void 0,
1446
+ ttlSeconds,
1447
+ progress,
1448
+ requestToken,
1449
+ state: _QueryStateTransformation.fromJson(state)
1450
+ };
1451
+ }
1452
+ _QueryStartResponseTransformation2.fromJson = fromJson;
1453
+ function toJson(model) {
1454
+ const { result, ttlSeconds, progress, requestToken, state } = model;
1455
+ return {
1456
+ result: result !== void 0 && result !== null ? _QueryResultTransformation.toJson(result) : void 0,
1457
+ ttlSeconds,
1458
+ progress,
1459
+ requestToken,
1460
+ state: _QueryStateTransformation.toJson(state)
1461
+ };
1462
+ }
1463
+ _QueryStartResponseTransformation2.toJson = toJson;
1464
+ })(_QueryStartResponseTransformation || (_QueryStartResponseTransformation = {}));
1465
+
1466
+ // packages/client/query/src/lib/utils/url-helpers.ts
1467
+ var encodeQueryParam = (key, value) => {
1468
+ const encodedKey = encodeURIComponent(key);
1469
+ return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : String(value))}`;
1470
+ };
1471
+ var addArrayQueryParam = (query, key) => {
1472
+ const arrayValue = query[key];
1473
+ return arrayValue.map((value) => encodeQueryParam(key, value)).join("&");
1474
+ };
1475
+ var addQueryParam = (query, key) => encodeQueryParam(key, query[key]);
1476
+ var toQueryString = (rawQuery) => {
1477
+ const query = rawQuery || {};
1478
+ const keys = Object.keys(query).filter((key) => typeof query[key] !== "undefined");
1479
+ return keys.map((key) => Array.isArray(query[key]) ? addArrayQueryParam(query, key) : addQueryParam(query, key)).join("&");
1480
+ };
1481
+
1482
+ // packages/client/query/src/lib/apis/query-execution-api.ts
1483
+ var QueryExecutionClient = class {
1484
+ httpClient;
1485
+ constructor(httpClientImplementation) {
1486
+ this.httpClient = httpClientImplementation;
1487
+ registerGlobalErrorSerializer(apiClientErrorSerializer);
1488
+ }
1489
+ async queryPoll(config) {
1490
+ if (!config) {
1491
+ throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
1492
+ }
1493
+ const query = toQueryString({
1494
+ "request-token": config.requestToken,
1495
+ "request-timeout-milliseconds": config.requestTimeoutMilliseconds,
1496
+ enrich: config.enrich
1497
+ });
1498
+ const response = await this.httpClient.send({
1499
+ url: `/platform/storage/query/v1/query:poll?${query}`,
1500
+ method: "GET",
1501
+ headers: {
1502
+ Accept: "application/json"
1503
+ },
1504
+ abortSignal: config.abortSignal,
1505
+ statusValidator: (status) => {
1506
+ if (200 <= status && status < 300) {
1507
+ return true;
1508
+ }
1509
+ return [410, 500].includes(status);
1510
+ }
1511
+ });
1512
+ switch (response.status) {
1513
+ case 410: {
1514
+ const responseValue = await response.body("text");
1515
+ throw new ClientRequestError(
1516
+ `410`,
1517
+ response,
1518
+ responseValue,
1519
+ `The query for the given request-token is not available anymore.`
1520
+ );
1521
+ }
1522
+ case 500: {
1523
+ const responseValue = await response.body("json");
1524
+ try {
1525
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
1526
+ throw new ErrorEnvelopeError("500", response, errorBody, "An internal server error has occurred.");
1527
+ } catch (err) {
1528
+ if (err instanceof ErrorEnvelopeError) {
1529
+ throw err;
1530
+ }
1531
+ throw new InvalidResponseError(
1532
+ `QueryExecutionClient.query:poll:500`,
1533
+ err,
1534
+ responseValue,
1535
+ "ErrorEnvelope",
1536
+ void 0
1537
+ );
1538
+ }
1539
+ }
1540
+ case 200: {
1541
+ const responseValue = await response.body("json");
1542
+ try {
1543
+ return _QueryPollResponseTransformation.fromJson(responseValue);
1544
+ } catch (err) {
1545
+ throw new InvalidResponseError(
1546
+ `QueryExecutionClient.query:poll:${response.status}`,
1547
+ err,
1548
+ responseValue,
1549
+ void 0,
1550
+ void 0
1551
+ );
1552
+ }
1553
+ }
1554
+ default: {
1555
+ const responseValue = await response.body("text").catch();
1556
+ throw new ClientRequestError(
1557
+ `${response.status}`,
1558
+ response,
1559
+ responseValue,
1560
+ `Unexpected api response: code=${response.status} body="${responseValue}"`
1561
+ );
1562
+ }
1563
+ }
1564
+ }
1565
+ async queryExecute(config) {
1566
+ if (!config) {
1567
+ throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
1568
+ }
1569
+ const encodedBody = _ExecuteRequestTransformation.toJson(config.body);
1570
+ const query = toQueryString({ enrich: config.enrich });
1571
+ const headerParameters = {
1572
+ ...config.authorization !== void 0 && { Authorization: String(config.authorization) }
1573
+ };
1574
+ const response = await this.httpClient.send({
1575
+ url: `/platform/storage/query/v1/query:execute?${query}`,
1576
+ method: "POST",
1577
+ requestBodyType: "json",
1578
+ body: encodedBody,
1579
+ headers: {
1580
+ "Content-Type": "application/json",
1581
+ Accept: "application/json",
1582
+ ...headerParameters
1583
+ },
1584
+ abortSignal: config.abortSignal,
1585
+ statusValidator: (status) => {
1586
+ if (200 <= status && status < 300) {
1587
+ return true;
1588
+ }
1589
+ return [400, 500, 503].includes(status);
1590
+ }
1591
+ });
1592
+ switch (response.status) {
1593
+ case 400: {
1594
+ const responseValue = await response.body("json");
1595
+ try {
1596
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
1597
+ throw new ErrorEnvelopeError(
1598
+ "400",
1599
+ response,
1600
+ errorBody,
1601
+ "The supplied request is wrong. Either the query itself or other parameters are wrong."
1602
+ );
1603
+ } catch (err) {
1604
+ if (err instanceof ErrorEnvelopeError) {
1605
+ throw err;
1606
+ }
1607
+ throw new InvalidResponseError(
1608
+ `QueryExecutionClient.query:execute:400`,
1609
+ err,
1610
+ responseValue,
1611
+ "ErrorEnvelope",
1612
+ void 0
1613
+ );
1614
+ }
1615
+ }
1616
+ case 500: {
1617
+ const responseValue = await response.body("json");
1618
+ try {
1619
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
1620
+ throw new ErrorEnvelopeError("500", response, errorBody, "An internal server error has occurred.");
1621
+ } catch (err) {
1622
+ if (err instanceof ErrorEnvelopeError) {
1623
+ throw err;
1624
+ }
1625
+ throw new InvalidResponseError(
1626
+ `QueryExecutionClient.query:execute:500`,
1627
+ err,
1628
+ responseValue,
1629
+ "ErrorEnvelope",
1630
+ void 0
1631
+ );
1632
+ }
1633
+ }
1634
+ case 503: {
1635
+ const responseValue = await response.body("json");
1636
+ try {
1637
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
1638
+ throw new ErrorEnvelopeError("503", response, errorBody, "Service is unavailable.");
1639
+ } catch (err) {
1640
+ if (err instanceof ErrorEnvelopeError) {
1641
+ throw err;
1642
+ }
1643
+ throw new InvalidResponseError(
1644
+ `QueryExecutionClient.query:execute:503`,
1645
+ err,
1646
+ responseValue,
1647
+ "ErrorEnvelope",
1648
+ void 0
1649
+ );
1650
+ }
1651
+ }
1652
+ case 200: {
1653
+ const responseValue = await response.body("json");
1654
+ try {
1655
+ return _QueryStartResponseTransformation.fromJson(responseValue);
1656
+ } catch (err) {
1657
+ throw new InvalidResponseError(
1658
+ `QueryExecutionClient.query:execute:${response.status}`,
1659
+ err,
1660
+ responseValue,
1661
+ void 0,
1662
+ void 0
1663
+ );
1664
+ }
1665
+ }
1666
+ case 202: {
1667
+ const responseValue = await response.body("json");
1668
+ try {
1669
+ return _QueryStartResponseTransformation.fromJson(responseValue);
1670
+ } catch (err) {
1671
+ throw new InvalidResponseError(
1672
+ `QueryExecutionClient.query:execute:${response.status}`,
1673
+ err,
1674
+ responseValue,
1675
+ void 0,
1676
+ void 0
1677
+ );
1678
+ }
1679
+ }
1680
+ default: {
1681
+ const responseValue = await response.body("text").catch();
1682
+ throw new ClientRequestError(
1683
+ `${response.status}`,
1684
+ response,
1685
+ responseValue,
1686
+ `Unexpected api response: code=${response.status} body="${responseValue}"`
1687
+ );
1688
+ }
1689
+ }
1690
+ }
1691
+ async queryCancel(config) {
1692
+ if (!config) {
1693
+ throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
1694
+ }
1695
+ const query = toQueryString({ "request-token": config.requestToken });
1696
+ const response = await this.httpClient.send({
1697
+ url: `/platform/storage/query/v1/query:cancel?${query}`,
1698
+ method: "POST",
1699
+ headers: {
1700
+ Accept: "application/json"
1701
+ },
1702
+ abortSignal: config.abortSignal,
1703
+ statusValidator: (status) => {
1704
+ if (200 <= status && status < 300) {
1705
+ return true;
1706
+ }
1707
+ return [410, 500].includes(status);
1708
+ }
1709
+ });
1710
+ switch (response.status) {
1711
+ case 410: {
1712
+ const responseValue = await response.body("text");
1713
+ throw new ClientRequestError(
1714
+ `410`,
1715
+ response,
1716
+ responseValue,
1717
+ `The query for the given request-token is not available anymore.`
1718
+ );
1719
+ }
1720
+ case 500: {
1721
+ const responseValue = await response.body("json");
1722
+ try {
1723
+ const errorBody = _ErrorEnvelopeTransformation.fromJson(responseValue);
1724
+ throw new ErrorEnvelopeError("500", response, errorBody, "An internal server error has occurred.");
1725
+ } catch (err) {
1726
+ if (err instanceof ErrorEnvelopeError) {
1727
+ throw err;
1728
+ }
1729
+ throw new InvalidResponseError(
1730
+ `QueryExecutionClient.query:cancel:500`,
1731
+ err,
1732
+ responseValue,
1733
+ "ErrorEnvelope",
1734
+ void 0
1735
+ );
1736
+ }
1737
+ }
1738
+ case 200: {
1739
+ const responseValue = await response.body("json");
1740
+ try {
1741
+ return _QueryPollResponseTransformation.fromJson(responseValue);
1742
+ } catch (err) {
1743
+ throw new InvalidResponseError(
1744
+ `QueryExecutionClient.query:cancel:${response.status}`,
1745
+ err,
1746
+ responseValue,
1747
+ void 0,
1748
+ void 0
1749
+ );
1750
+ }
1751
+ }
1752
+ case 202: {
1753
+ return;
1754
+ }
1755
+ default: {
1756
+ const responseValue = await response.body("text").catch();
1757
+ throw new ClientRequestError(
1758
+ `${response.status}`,
1759
+ response,
1760
+ responseValue,
1761
+ `Unexpected api response: code=${response.status} body="${responseValue}"`
1762
+ );
1763
+ }
1764
+ }
1765
+ }
1766
+ };
1767
+ var queryExecutionClient = /* @__PURE__ */ new QueryExecutionClient(import_http_client2.httpClient);
1768
+
1769
+ // packages/client/query/src/lib/models/geo-point.ts
1770
+ var _GeoPointTransformation;
1771
+ ((_GeoPointTransformation2) => {
1772
+ function fromJson(model) {
1773
+ const { latitude, longitude } = model;
1774
+ return {
1775
+ latitude,
1776
+ longitude
1777
+ };
1778
+ }
1779
+ _GeoPointTransformation2.fromJson = fromJson;
1780
+ function toJson(model) {
1781
+ const { latitude, longitude } = model;
1782
+ return {
1783
+ latitude,
1784
+ longitude
1785
+ };
1786
+ }
1787
+ _GeoPointTransformation2.toJson = toJson;
1788
+ })(_GeoPointTransformation || (_GeoPointTransformation = {}));