@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.
- package/CHANGELOG.md +9 -0
- package/LICENSE +174 -0
- package/README.md +54 -0
- package/cjs/index.js +1788 -0
- package/docs/DOCS.md +2833 -0
- package/dynatrace-metadata.json +18 -0
- package/esm/index.js +1766 -0
- package/package.json +11 -0
- package/types/index.d.ts +1 -0
- package/types/packages/client/query/src/index.d.ts +1 -0
- package/types/packages/client/query/src/lib/apis/index.d.ts +2 -0
- package/types/packages/client/query/src/lib/apis/query-assistance-api.d.ts +276 -0
- package/types/packages/client/query/src/lib/apis/query-execution-api.d.ts +337 -0
- package/types/packages/client/query/src/lib/error-envelopes/api-client-error.d.ts +9 -0
- package/types/packages/client/query/src/lib/error-envelopes/client-request-error.d.ts +8 -0
- package/types/packages/client/query/src/lib/error-envelopes/error-envelope-error.d.ts +8 -0
- package/types/packages/client/query/src/lib/error-envelopes/error-serializer.d.ts +3 -0
- package/types/packages/client/query/src/lib/error-envelopes/index.d.ts +3 -0
- package/types/packages/client/query/src/lib/error-envelopes/invalid-response-error.d.ts +8 -0
- package/types/packages/client/query/src/lib/index.d.ts +3 -0
- package/types/packages/client/query/src/lib/models/autocomplete-request.d.ts +26 -0
- package/types/packages/client/query/src/lib/models/autocomplete-response.d.ts +28 -0
- package/types/packages/client/query/src/lib/models/autocomplete-suggestion-part.d.ts +30 -0
- package/types/packages/client/query/src/lib/models/autocomplete-suggestion.d.ts +28 -0
- package/types/packages/client/query/src/lib/models/dql-alternative-node.d.ts +18 -0
- package/types/packages/client/query/src/lib/models/dql-container-node.d.ts +23 -0
- package/types/packages/client/query/src/lib/models/dql-node-node-type.d.ts +14 -0
- package/types/packages/client/query/src/lib/models/dql-node.d.ts +29 -0
- package/types/packages/client/query/src/lib/models/dql-terminal-node.d.ts +26 -0
- package/types/packages/client/query/src/lib/models/error-envelope.d.ts +18 -0
- package/types/packages/client/query/src/lib/models/error-response-details.d.ts +50 -0
- package/types/packages/client/query/src/lib/models/error-response.d.ts +25 -0
- package/types/packages/client/query/src/lib/models/execute-request.d.ts +64 -0
- package/types/packages/client/query/src/lib/models/field-type-type.d.ts +21 -0
- package/types/packages/client/query/src/lib/models/field-type.d.ts +18 -0
- package/types/packages/client/query/src/lib/models/geo-point.d.ts +22 -0
- package/types/packages/client/query/src/lib/models/grail-metadata.d.ts +66 -0
- package/types/packages/client/query/src/lib/models/index.d.ts +35 -0
- package/types/packages/client/query/src/lib/models/metadata-notification.d.ts +45 -0
- package/types/packages/client/query/src/lib/models/metadata.d.ts +18 -0
- package/types/packages/client/query/src/lib/models/metric-metadata.d.ts +32 -0
- package/types/packages/client/query/src/lib/models/parse-request.d.ts +24 -0
- package/types/packages/client/query/src/lib/models/position-info.d.ts +27 -0
- package/types/packages/client/query/src/lib/models/query-poll-response.d.ts +28 -0
- package/types/packages/client/query/src/lib/models/query-result.d.ts +27 -0
- package/types/packages/client/query/src/lib/models/query-start-response.d.ts +33 -0
- package/types/packages/client/query/src/lib/models/query-state.d.ts +17 -0
- package/types/packages/client/query/src/lib/models/ranged-field-types-mappings.d.ts +15 -0
- package/types/packages/client/query/src/lib/models/ranged-field-types.d.ts +20 -0
- package/types/packages/client/query/src/lib/models/result-record-value.d.ts +13 -0
- package/types/packages/client/query/src/lib/models/result-record.d.ts +15 -0
- package/types/packages/client/query/src/lib/models/timeframe.d.ts +22 -0
- package/types/packages/client/query/src/lib/models/token-position.d.ts +20 -0
- package/types/packages/client/query/src/lib/models/token-type.d.ts +48 -0
- package/types/packages/client/query/src/lib/models/verify-request.d.ts +24 -0
- package/types/packages/client/query/src/lib/models/verify-response.d.ts +23 -0
- package/types/packages/client/query/src/lib/utils/url-helpers.d.ts +3 -0
- package/types/packages/http-client/src/index.d.ts +2 -0
- package/types/packages/http-client/src/lib/platform/abort-controller.d.ts +6 -0
- package/types/packages/http-client/src/lib/platform/abort-signal.d.ts +6 -0
- package/types/packages/http-client/src/lib/platform/apply-content-type-header.d.ts +2 -0
- package/types/packages/http-client/src/lib/platform/base-error.d.ts +5 -0
- package/types/packages/http-client/src/lib/platform/binary.d.ts +13 -0
- package/types/packages/http-client/src/lib/platform/data-type-error.d.ts +6 -0
- package/types/packages/http-client/src/lib/platform/decode-response-body.d.ts +3 -0
- package/types/packages/http-client/src/lib/platform/default-status-validator.d.ts +2 -0
- package/types/packages/http-client/src/lib/platform/encode-request-body.d.ts +2 -0
- package/types/packages/http-client/src/lib/platform/http-client-abort-error.d.ts +7 -0
- package/types/packages/http-client/src/lib/platform/http-client-request-error.d.ts +7 -0
- package/types/packages/http-client/src/lib/platform/http-client-response-error-serializer.d.ts +1 -0
- package/types/packages/http-client/src/lib/platform/http-client-response-error.d.ts +8 -0
- package/types/packages/http-client/src/lib/platform/http-client-response.d.ts +10 -0
- package/types/packages/http-client/src/lib/platform/http-client.d.ts +5 -0
- package/types/packages/http-client/src/lib/platform/index.d.ts +11 -0
- package/types/packages/http-client/src/lib/platform/unsupported-operation-error.d.ts +6 -0
- package/types/packages/http-client/src/lib/types/abort-controller.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/abort-signal.d.ts +15 -0
- package/types/packages/http-client/src/lib/types/base-error.d.ts +4 -0
- package/types/packages/http-client/src/lib/types/binary.d.ts +15 -0
- package/types/packages/http-client/src/lib/types/data-type-error.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/data-types.d.ts +36 -0
- package/types/packages/http-client/src/lib/types/form-data-request-body.d.ts +83 -0
- package/types/packages/http-client/src/lib/types/form-data-response-body.d.ts +15 -0
- package/types/packages/http-client/src/lib/types/headers.d.ts +6 -0
- package/types/packages/http-client/src/lib/types/http-client-abort-error.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/http-client-network-error.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/http-client-request-error.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/http-client-request-options.d.ts +42 -0
- package/types/packages/http-client/src/lib/types/http-client-response-error.d.ts +19 -0
- package/types/packages/http-client/src/lib/types/http-client-response.d.ts +33 -0
- package/types/packages/http-client/src/lib/types/http-client.d.ts +24 -0
- package/types/packages/http-client/src/lib/types/index.d.ts +20 -0
- package/types/packages/http-client/src/lib/types/request-body-types.d.ts +26 -0
- package/types/packages/http-client/src/lib/types/response-body-types.d.ts +46 -0
- package/types/packages/http-client/src/lib/types/status-validator.d.ts +7 -0
- package/types/packages/http-client/src/lib/types/unsupported-operation-error.d.ts +14 -0
- package/types/packages/platform/error-handlers/src/index.d.ts +2 -0
- package/types/packages/platform/error-handlers/src/lib/add-global-error-serializer.d.ts +13 -0
- package/types/packages/platform/error-handlers/src/lib/types/common-serialized-error.d.ts +10 -0
- package/types/packages/platform/error-handlers/src/lib/types/dt-runtime-error-handlers.d.ts +5 -0
- package/types/packages/platform/error-handlers/src/lib/types/error-type.d.ts +9 -0
- package/types/packages/platform/error-handlers/src/lib/types/global-dt-runtime-with-error-handlers.d.ts +7 -0
- package/types/packages/platform/error-handlers/src/lib/types/global-error-serializer.d.ts +10 -0
- package/types/packages/platform/error-handlers/src/lib/types/http-serialized-error.d.ts +11 -0
- package/types/packages/platform/error-handlers/src/lib/types/index.d.ts +6 -0
- package/types/packages/platform/error-handlers/src/lib/types/serialized-error.d.ts +8 -0
- package/types/packages/platform/shared/index.d.ts +1 -0
- package/types/packages/platform/shared/utils/get-global-with-dt-runtime.d.ts +1 -0
package/package.json
ADDED
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './packages/client/query/src';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { AbortSignal, HttpClient } from '@dynatrace-sdk/http-client';
|
|
2
|
+
import { AutocompleteRequest } from '../models/autocomplete-request';
|
|
3
|
+
import { AutocompleteResponse } from '../models/autocomplete-response';
|
|
4
|
+
import { DQLNode } from '../models/dql-node';
|
|
5
|
+
import { ParseRequest } from '../models/parse-request';
|
|
6
|
+
import { VerifyRequest } from '../models/verify-request';
|
|
7
|
+
import { VerifyResponse } from '../models/verify-response';
|
|
8
|
+
/**
|
|
9
|
+
* Supporting operations for the Query. Also known as the Language services.
|
|
10
|
+
*/
|
|
11
|
+
export declare class QueryAssistanceClient {
|
|
12
|
+
private httpClient;
|
|
13
|
+
/**
|
|
14
|
+
* @param {HttpClient} httpClientImplementation - You can provide custom http client as a parameter to constructor of a QueryAssistanceClient. Custom http client should implement {HttpClient} interface.
|
|
15
|
+
* @example
|
|
16
|
+
* const queryClientNodeJs = new QueryClient(yourCustomImplementation);
|
|
17
|
+
*/
|
|
18
|
+
constructor(httpClientImplementation: HttpClient);
|
|
19
|
+
/**
|
|
20
|
+
* Verifies a query without executing it.
|
|
21
|
+
*
|
|
22
|
+
* ## Overview
|
|
23
|
+
*
|
|
24
|
+
* Verifies the supplied query string and other query parameters for lack of any errors, but without actually
|
|
25
|
+
* submitting the query for execution.
|
|
26
|
+
* @returns Supplied query and parameters were verified.
|
|
27
|
+
*/
|
|
28
|
+
queryVerify(config: {
|
|
29
|
+
body: VerifyRequest;
|
|
30
|
+
/** The authorization context. Typically start with 'Bearer '. */ authorization?: string;
|
|
31
|
+
abortSignal?: AbortSignal;
|
|
32
|
+
}): Promise<VerifyResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Get a structured tree of the canonical form of the query.
|
|
35
|
+
*
|
|
36
|
+
* ## Overview
|
|
37
|
+
*
|
|
38
|
+
* Returns the parsed query as a tree, containing the structure of the canonical query. Tree-nodes can contain references to
|
|
39
|
+
* the token position where they originate from. This may help to provide hover effects, show canonical forms, mark
|
|
40
|
+
* optional items, and more.
|
|
41
|
+
*
|
|
42
|
+
* ## Details
|
|
43
|
+
*
|
|
44
|
+
* The query tree consists of nodes that contain different additional information (everything optional):
|
|
45
|
+
*
|
|
46
|
+
* ### General Fields
|
|
47
|
+
*
|
|
48
|
+
* Field | Mandatory | Description
|
|
49
|
+
* ----------------------- | --- | ----------------------------------------------------------------------------------------
|
|
50
|
+
* tokenPosition | no | optional. If present, it represents the position within the query string where the node refers to.
|
|
51
|
+
* isOptional | no | whether this node could be left out and the result would still be the same query (semantically).
|
|
52
|
+
*
|
|
53
|
+
* #### tokenPosition
|
|
54
|
+
*
|
|
55
|
+
* contains `start` (inclusive) and `end` (inclusive), both contain `index` (0 based; fur substrings), `line`
|
|
56
|
+
* and `column` (both 1-based; for readability).
|
|
57
|
+
*
|
|
58
|
+
* * If `tokenPosition` is present, it always contains start and end with all fields
|
|
59
|
+
* * If `tokenPosition` is not present, there might still be nested nodes that do contain a position
|
|
60
|
+
* * If `start == end`, the position refers to a single character
|
|
61
|
+
* * If `start > end`, we know for sure that something was inserted.
|
|
62
|
+
*
|
|
63
|
+
* We can always check whether the canonical representation of a node matches the text in the tokenPosition to see whether
|
|
64
|
+
* something was inserted, removed, or changed.
|
|
65
|
+
*
|
|
66
|
+
* #### isOptional
|
|
67
|
+
*
|
|
68
|
+
* only present if it is true.
|
|
69
|
+
*
|
|
70
|
+
* Optional nodes can e.g. be optional braces that make a query more readable, but are not necessary. This could be used to
|
|
71
|
+
* enter *ghost braces* and *implicit functions* in the user's input field; maybe with different formatting
|
|
72
|
+
* (using the tokenPosition of sibling nodes we can also check whether the user wrote these or not).
|
|
73
|
+
*
|
|
74
|
+
* ### Advanced Token Types
|
|
75
|
+
*
|
|
76
|
+
* each node is of one of following types and may contain more fields:
|
|
77
|
+
*
|
|
78
|
+
* * Terminal Node
|
|
79
|
+
* * ContainerNode
|
|
80
|
+
* * Alternative Node
|
|
81
|
+
*
|
|
82
|
+
* #### Terminal Node
|
|
83
|
+
*
|
|
84
|
+
* can be identified by checking whether `canonicalString` is present
|
|
85
|
+
*
|
|
86
|
+
* Field | Mandatory | Description
|
|
87
|
+
* ------------------------ | --- | ---------------------------------------------------------------------------------------
|
|
88
|
+
* type | yes | the type of the terminal node - do not confuse with the type of container nodes
|
|
89
|
+
* canonicalString | yes | the canonical string representation. Concatenating the canonicalString of all nested terminal nodes provides the canonical form of the query.
|
|
90
|
+
* isMandatoryOnUserOrder | no | may only be present if (`type="BRACE_OPEN"` or `type="BRACE_CLOSE"`) and `isOptional=true`. For usage see section [Special node type: PARAMETERS](#special-node-type-parameters)
|
|
91
|
+
*
|
|
92
|
+
* ##### Current types of terminal nodes (list might grow):
|
|
93
|
+
*
|
|
94
|
+
* * SPACE
|
|
95
|
+
* * LINEBREAK
|
|
96
|
+
* * INDENT
|
|
97
|
+
* * PIPE
|
|
98
|
+
* * DOT
|
|
99
|
+
* * COLON
|
|
100
|
+
* * COMMA
|
|
101
|
+
* * BRACE_OPEN
|
|
102
|
+
* * BRACE_CLOSE
|
|
103
|
+
* * BRACKET_OPEN
|
|
104
|
+
* * BRACKET_CLOSE
|
|
105
|
+
* * PARENTHESIS_OPEN
|
|
106
|
+
* * PARENTHESIS_CLOSE
|
|
107
|
+
* * QUOTE
|
|
108
|
+
* * SLASH
|
|
109
|
+
* * BOOLEAN_TRUE
|
|
110
|
+
* * BOOLEAN_FALSE
|
|
111
|
+
* * NULL
|
|
112
|
+
* * COMMAND_NAME
|
|
113
|
+
* * PARAMETER_KEY
|
|
114
|
+
* * PARAMETER_VALUE_SCOPE
|
|
115
|
+
* * FUNCTION_NAME
|
|
116
|
+
* * OPERATOR
|
|
117
|
+
* * TRAVERSAL_OPERATOR
|
|
118
|
+
* * TRAVERSAL_RELATION_NAME
|
|
119
|
+
* * TRAVERSAL_HOP_COUNT
|
|
120
|
+
* * SIMPLE_IDENTIFIER
|
|
121
|
+
* * NUMBER
|
|
122
|
+
* * STRING
|
|
123
|
+
* * TIME_UNIT
|
|
124
|
+
* * TIMESTAMP_VALUE
|
|
125
|
+
* * METRIC_KEY
|
|
126
|
+
* * VARIABLE
|
|
127
|
+
*
|
|
128
|
+
* #### ContainerNode
|
|
129
|
+
*
|
|
130
|
+
* can be identified by checking whether `children` is present
|
|
131
|
+
*
|
|
132
|
+
* Field | Mandatory | Description
|
|
133
|
+
* ----------------------- | --- | ----------------------------------------------------------------------------------------
|
|
134
|
+
* type | yes | the type of the container node - do not confuse with the type of terminal nodes
|
|
135
|
+
* children | yes | the children for the node. might be of any type
|
|
136
|
+
*
|
|
137
|
+
* ##### Current types of container nodes (list might grow):
|
|
138
|
+
*
|
|
139
|
+
* * QUERY
|
|
140
|
+
* * EXECUTION_BLOCK
|
|
141
|
+
* * COMMAND
|
|
142
|
+
* * COMMAND_SEPARATOR
|
|
143
|
+
* * PARAMETER_WITH_KEY
|
|
144
|
+
* * GROUP
|
|
145
|
+
* * PARAMETERS - check examples further down
|
|
146
|
+
* * PARAMETER_NAMING
|
|
147
|
+
* * PARAMETER_SEPARATOR
|
|
148
|
+
* * FUNCTION
|
|
149
|
+
* * FUNCTION_PART - check examples further down
|
|
150
|
+
* * EXPRESSION
|
|
151
|
+
* * IDENTIFIER
|
|
152
|
+
* * SOURCE_ID
|
|
153
|
+
* * DURATION
|
|
154
|
+
* * TIMESTAMP
|
|
155
|
+
* * TIMEFRAME
|
|
156
|
+
* * TRAVERSAL_PATH
|
|
157
|
+
* * TRAVERSAL_STEP
|
|
158
|
+
*
|
|
159
|
+
* ##### Special node type: PARAMETERS
|
|
160
|
+
*
|
|
161
|
+
* can contain children representing the parameters. Every second child is of type PARAMETER_SEPARATOR.
|
|
162
|
+
*
|
|
163
|
+
* You may reorder the children based on their tokenPosition to get the user order. However, in this case,
|
|
164
|
+
* you need to consider `isMandatoryOnUserOrder` to determine whether the grouping braces are mandatory or not.
|
|
165
|
+
*
|
|
166
|
+
* ###### Example
|
|
167
|
+
*
|
|
168
|
+
* For the query `SORT a, {direction:"descending", b}`, the canonical form is:
|
|
169
|
+
*
|
|
170
|
+
* `SORT a, {b, direction:"descending"}`
|
|
171
|
+
*
|
|
172
|
+
* This is the order, in which the parameters are returned in the query tree.
|
|
173
|
+
* Parameters are {a} and {{b} and {direction:"descending"}}. In this case, the braces are optional.
|
|
174
|
+
*
|
|
175
|
+
* `SORT a, {b, direction:"descending"}` is equivalent to `SORT a, b, direction:"descending"`
|
|
176
|
+
*
|
|
177
|
+
* However, if you reorder the children by tokenPosition, the braces are not optional, because
|
|
178
|
+
*
|
|
179
|
+
* `SORT a, direction:"descending", b` is interpreted as `SORT {a, direction:"descending"}, b`
|
|
180
|
+
*
|
|
181
|
+
* So, if the children in PARAMETERS are re-ordered by tokenPosition, braces (or in general: TerminalNodes)
|
|
182
|
+
* are only optional if `isOptional && !isMandatoryOnUserOrder`.
|
|
183
|
+
*
|
|
184
|
+
* ##### Special node type: FUNCTION_PART
|
|
185
|
+
*
|
|
186
|
+
* A container node of type `FUNCTION` may contain nodes of type `FUNCTION_PART`.
|
|
187
|
+
*
|
|
188
|
+
* If those `FUNCTION_PART`s are marked as optional, this means you have to either include *all* or *none* of these
|
|
189
|
+
* optional function parts.
|
|
190
|
+
*
|
|
191
|
+
* *Example*:
|
|
192
|
+
*
|
|
193
|
+
* `filter anyMatch(a.b == 1, input:a)`
|
|
194
|
+
*
|
|
195
|
+
* The optional function parts are `anyMatch(` and `, input:a)`. If you leave out both, the command will still work:
|
|
196
|
+
* `filter a.b == 1` and return the same result. Using one of these optional function parts and removing the other will lead
|
|
197
|
+
* to an invalid query.
|
|
198
|
+
*
|
|
199
|
+
* #### Alternative Node
|
|
200
|
+
*
|
|
201
|
+
* can be identified by checking whether `alternatives` is present
|
|
202
|
+
*
|
|
203
|
+
* Field | Mandatory | Description
|
|
204
|
+
* ----------------------- | --- | ----------------------------------------------------------------------------------------
|
|
205
|
+
* alternatives | yes | Type: Map<AlternativeType, DQLNode>
|
|
206
|
+
*
|
|
207
|
+
* When displaying the query, pick one option. You may use the other options for hovering, replacing, and more.
|
|
208
|
+
*
|
|
209
|
+
* ##### Current values of AlternativeType (list might grow):
|
|
210
|
+
*
|
|
211
|
+
* * CANONICAL: This node is the one we will use for our canonical form
|
|
212
|
+
* * USER: An alternative that is also valid, but not canonical; and this version was picked by the user.
|
|
213
|
+
* * INFO: only if the canonical version is not present
|
|
214
|
+
*
|
|
215
|
+
* *Examples*:
|
|
216
|
+
*
|
|
217
|
+
* * `CANONICAL` is not present, `USER` is present: user's nodes are optional, but not canonical (usually optional nodes
|
|
218
|
+
* are still canonical)
|
|
219
|
+
* * `CANONICAL` is present, `USER` is not present: same as if the canonical node was optional. If this happens, it is
|
|
220
|
+
* likely that there is also an `INFO` node
|
|
221
|
+
* * `CANONICAL` is present, `USER` is present: there are different alternatives
|
|
222
|
+
* * `INFO` is present: usually if `CANONICAL` is not present (e.g. the parameter key for `FILTER a == 1`), there is an info node
|
|
223
|
+
* for `FILTER condition:a == 1`. This `condition:` was neither written by the user nor is it canonical; but it might be
|
|
224
|
+
* used to help the user understand what this parameter means.
|
|
225
|
+
* @returns A node containing more nodes, a node offering different (semantically equivalent) versions of the query parts, or a terminal node that shows the canonical form.
|
|
226
|
+
*/
|
|
227
|
+
queryParse(config: {
|
|
228
|
+
body: ParseRequest;
|
|
229
|
+
/** The authorization context. Typically start with 'Bearer '. */ authorization?: string;
|
|
230
|
+
abortSignal?: AbortSignal;
|
|
231
|
+
}): Promise<DQLNode>;
|
|
232
|
+
/**
|
|
233
|
+
* Get a structured list of suggestions for the query at the given position.
|
|
234
|
+
*
|
|
235
|
+
* ## Overview
|
|
236
|
+
*
|
|
237
|
+
* We provide a list of suggestions that may be used after the cursor position. The following queries will all provide the
|
|
238
|
+
* same results:
|
|
239
|
+
*
|
|
240
|
+
* * `query: "f"`
|
|
241
|
+
* * `query: "f", cursorPosition:1`
|
|
242
|
+
* * `query: "fetch ", cursorPosition:1`
|
|
243
|
+
*
|
|
244
|
+
* Available fields:
|
|
245
|
+
*
|
|
246
|
+
* | Field | Description |
|
|
247
|
+
* |-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
248
|
+
* | suggestions | a list of suggestions. Each item is a separate possible suggestion, despite they might have the same outputs. |
|
|
249
|
+
* | optional | whether the suggestion is optional. If `true`, the query until the cursor position might work. If `false`, the query is definitely incomplete or invalid if cut at the cursor position. |
|
|
250
|
+
*
|
|
251
|
+
* Fields in the `suggestions`
|
|
252
|
+
*
|
|
253
|
+
* | Field | Description |
|
|
254
|
+
* |------------------------|------------------------------------------------------------------------------------------------------------|
|
|
255
|
+
* | suggestion | a string representing the whole suggestion. This information could also be derived from the parts. |
|
|
256
|
+
* | alreadyTypedCharacters | how many characters of this suggestion have already been typed (and will be overridden by the suggestion). |
|
|
257
|
+
* | parts | a list of semantically enriched information on what are the parts of a suggestion. |
|
|
258
|
+
*
|
|
259
|
+
* Fields in `parts`
|
|
260
|
+
*
|
|
261
|
+
* | Field | Description |
|
|
262
|
+
* |------------|-----------------------------------------------------------|
|
|
263
|
+
* | suggestion | a string representing the current part of the suggestion. |
|
|
264
|
+
* | type | current types: SPACE, PIPE, COMMAND (may be extended) |
|
|
265
|
+
*
|
|
266
|
+
* The `type` helps to treat specific parts of the suggestion different to others; either by a different visualization,
|
|
267
|
+
* a link to docs, etc.
|
|
268
|
+
* @returns A list of structured autocomplete suggestions.
|
|
269
|
+
*/
|
|
270
|
+
queryAutocomplete(config: {
|
|
271
|
+
body: AutocompleteRequest;
|
|
272
|
+
/** The authorization context. Typically start with 'Bearer '. */ authorization?: string;
|
|
273
|
+
abortSignal?: AbortSignal;
|
|
274
|
+
}): Promise<AutocompleteResponse>;
|
|
275
|
+
}
|
|
276
|
+
export declare const queryAssistanceClient: QueryAssistanceClient;
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { AbortSignal, HttpClient } from '@dynatrace-sdk/http-client';
|
|
2
|
+
import { ExecuteRequest } from '../models/execute-request';
|
|
3
|
+
import { QueryPollResponse } from '../models/query-poll-response';
|
|
4
|
+
import { QueryStartResponse } from '../models/query-start-response';
|
|
5
|
+
/**
|
|
6
|
+
* Operations related to the Query execution.
|
|
7
|
+
*/
|
|
8
|
+
export declare class QueryExecutionClient {
|
|
9
|
+
private httpClient;
|
|
10
|
+
/**
|
|
11
|
+
* @param {HttpClient} httpClientImplementation - You can provide custom http client as a parameter to constructor of a QueryExecutionClient. Custom http client should implement {HttpClient} interface.
|
|
12
|
+
* @example
|
|
13
|
+
* const queryClientNodeJs = new QueryClient(yourCustomImplementation);
|
|
14
|
+
*/
|
|
15
|
+
constructor(httpClientImplementation: HttpClient);
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves query status and final result from Grail.
|
|
18
|
+
*
|
|
19
|
+
* ### Overview:
|
|
20
|
+
*
|
|
21
|
+
* Polls the status of a Grail query. Returns the status of the query, including the result if the query finished.
|
|
22
|
+
*
|
|
23
|
+
* ### The response format:
|
|
24
|
+
* The response consists of:
|
|
25
|
+
* * The state of the query.
|
|
26
|
+
* * ttlSeconds until the query will be wiped
|
|
27
|
+
* * If the query succeeded, also a result
|
|
28
|
+
*
|
|
29
|
+
* ```json
|
|
30
|
+
* {
|
|
31
|
+
* "state":"RUNNING",
|
|
32
|
+
* "ttlSeconds":197
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* The result has two main sections:
|
|
37
|
+
* * The 'records' section contains the individual records, where each record consists of a set of fields and their corresponding values.
|
|
38
|
+
* * The 'types' section describes the corresponding data types that a record field has.
|
|
39
|
+
*
|
|
40
|
+
* Every record has an implicit 'index' according to the position in the 'records' JSON array.
|
|
41
|
+
* The types section has a list of 1..N possible type 'buckets'. Each such bucket has an 'indexRange' which indicates which
|
|
42
|
+
* records will find their field types in which bucket. The index range has two values start & end and can be thought of as [startIndex, endIndex).
|
|
43
|
+
*
|
|
44
|
+
* A field part of a record with index 'i' will find its corresponding field type by first locating the bucket that satisfies:
|
|
45
|
+
*
|
|
46
|
+
* ```text
|
|
47
|
+
* startIndex <= i <= endIndex
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* Once the bucket is found the 'mappings' object has an entry for all the fields that are part of that record with index 'i'.
|
|
51
|
+
*
|
|
52
|
+
*
|
|
53
|
+
* Since enforcement of a particular schema is absent at ingestion time, it is possible to have records that share the same
|
|
54
|
+
* field name but their values are of a different type. This phenomenon will hence forth be named as a **"collision"**.
|
|
55
|
+
* When a collision does occur, we will create a new type 'bucket' that will have a different index range where
|
|
56
|
+
* the new record field types will be placed.
|
|
57
|
+
* It is guaranteed that every field of every record will have a corresponding type.
|
|
58
|
+
* **Clients should always take the included types into account when consuming records!**
|
|
59
|
+
*
|
|
60
|
+
* As an example, the following response highlights a collision, where a field called "cancelled" was ingested both as a
|
|
61
|
+
* boolean but also wrongly as a string. The first record contains the field "cancelled" as a string, but the very next record has the
|
|
62
|
+
* field with the same name but of boolean type. The types section has two entries. One corresponds to first record that has
|
|
63
|
+
* the field cancelled of type string. The second entry in the types section corresponds to the subsequent records which have
|
|
64
|
+
* the boolean field type.
|
|
65
|
+
*
|
|
66
|
+
* ```json
|
|
67
|
+
* {
|
|
68
|
+
* "state":"SUCCEEDED",
|
|
69
|
+
* "result": {
|
|
70
|
+
* "records": [
|
|
71
|
+
* {
|
|
72
|
+
* "type": "user_event",
|
|
73
|
+
* "order_id": "1ea34-2515-1515-fe1g",
|
|
74
|
+
* "cancelled": "true"
|
|
75
|
+
* },
|
|
76
|
+
* {
|
|
77
|
+
* "type": "user_event",
|
|
78
|
+
* "order_id": "2ea34-2515-1515-fe1g",
|
|
79
|
+
* "cancelled": false
|
|
80
|
+
* },
|
|
81
|
+
* {
|
|
82
|
+
* "type": "user_event",
|
|
83
|
+
* "order_id": "3ea34-2515-1515-fe1g",
|
|
84
|
+
* "cancelled": true
|
|
85
|
+
* },
|
|
86
|
+
* {
|
|
87
|
+
* "type": "user_event",
|
|
88
|
+
* "order_id": "4ea34-2515-1515-fe1g",
|
|
89
|
+
* "cancelled": false
|
|
90
|
+
* }
|
|
91
|
+
* ],
|
|
92
|
+
* "types": [
|
|
93
|
+
* {
|
|
94
|
+
* "indexRange": [
|
|
95
|
+
* 0,
|
|
96
|
+
* 1
|
|
97
|
+
* ],
|
|
98
|
+
* "mappings": {
|
|
99
|
+
* "type": {
|
|
100
|
+
* "type": "string"
|
|
101
|
+
* },
|
|
102
|
+
* "order_id": {
|
|
103
|
+
* "type": "string"
|
|
104
|
+
* },
|
|
105
|
+
* "cancelled": {
|
|
106
|
+
* "type": "string"
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
109
|
+
* },
|
|
110
|
+
* {
|
|
111
|
+
* "indexRange": [
|
|
112
|
+
* 1,
|
|
113
|
+
* 4
|
|
114
|
+
* ],
|
|
115
|
+
* "mappings": {
|
|
116
|
+
* "type": {
|
|
117
|
+
* "type": "string"
|
|
118
|
+
* },
|
|
119
|
+
* "order_id": {
|
|
120
|
+
* "type": "string"
|
|
121
|
+
* },
|
|
122
|
+
* "cancelled": {
|
|
123
|
+
* "type": "boolean"
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* ],
|
|
128
|
+
* "metadata": {
|
|
129
|
+
* "query": "fetch events | ...",
|
|
130
|
+
* "dqlVersion": "V0_3",
|
|
131
|
+
* "appliedTimeframe": {
|
|
132
|
+
* "start": 1657624357056,
|
|
133
|
+
* "end": 1657631557056
|
|
134
|
+
* },
|
|
135
|
+
* "timezone": "Z",
|
|
136
|
+
* "locale": ""
|
|
137
|
+
* }
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* The possible Grail types ened in the "types" section is limited to a list of well-defined types:
|
|
143
|
+
* ```
|
|
144
|
+
* BOOLEAN
|
|
145
|
+
* STRING
|
|
146
|
+
* DOUBLE
|
|
147
|
+
* LONG
|
|
148
|
+
* TIMESTAMP
|
|
149
|
+
* TIMEFRAME
|
|
150
|
+
* DURATION
|
|
151
|
+
* BINARY
|
|
152
|
+
* IP_ADDRESS
|
|
153
|
+
* GEO_POINT
|
|
154
|
+
* ARRAY
|
|
155
|
+
* RECORD
|
|
156
|
+
* ```
|
|
157
|
+
* @returns The current status and results of the supplied query.
|
|
158
|
+
*/
|
|
159
|
+
queryPoll(config: {
|
|
160
|
+
/** The request-token of the query. */ requestToken: string;
|
|
161
|
+
/** The request timeout in milliseconds. The response will be delayed for up to the specified time in milliseconds to wait for the result of the query. */ requestTimeoutMilliseconds?: number;
|
|
162
|
+
/** If set additional data will be available in the metadata section. */ enrich?: string;
|
|
163
|
+
abortSignal?: AbortSignal;
|
|
164
|
+
}): Promise<QueryPollResponse>;
|
|
165
|
+
/**
|
|
166
|
+
* Starts a Grail query.
|
|
167
|
+
*
|
|
168
|
+
* ### Overview:
|
|
169
|
+
*
|
|
170
|
+
* Executes a query and returns a list of records.
|
|
171
|
+
*
|
|
172
|
+
* For details about the query language see the [Dynatrace Query Language documentation](https://dt-url.net/bv03yk8).
|
|
173
|
+
*
|
|
174
|
+
* ### The response format:
|
|
175
|
+
*
|
|
176
|
+
* The json response will contain the state of the started query and a request token to reference it in future polling requests:
|
|
177
|
+
*
|
|
178
|
+
* ```json
|
|
179
|
+
* {
|
|
180
|
+
* "state":"RUNNING",
|
|
181
|
+
* "requestToken":"5tCm27WbTHmyi+749/wGsw==",
|
|
182
|
+
* "ttlSeconds":197
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
* @returns The final status and results of the supplied query if it finished within a supplied request-timeout-milliseconds. | The status of the query to start.
|
|
186
|
+
*/
|
|
187
|
+
queryExecute(config: {
|
|
188
|
+
body: ExecuteRequest;
|
|
189
|
+
/** If set additional data will be available in the metadata section. */ enrich?: string;
|
|
190
|
+
/** The authorization context. Typically start with 'Bearer '. */ authorization?: string;
|
|
191
|
+
abortSignal?: AbortSignal;
|
|
192
|
+
}): Promise<QueryStartResponse>;
|
|
193
|
+
/**
|
|
194
|
+
* Cancels the query and returns the result if the query was already finished, otherwise discards it.
|
|
195
|
+
*
|
|
196
|
+
* ### Overview:
|
|
197
|
+
*
|
|
198
|
+
* Cancels a running Grail query and returns a list of records if the query already finished.
|
|
199
|
+
*
|
|
200
|
+
* ### The response format:
|
|
201
|
+
*
|
|
202
|
+
* If the query was already finished, a response body including the result will be returned. Otherwise the response will contain no body.
|
|
203
|
+
*
|
|
204
|
+
* The result has three main sections:
|
|
205
|
+
* * the 'records' section contains the individual records, where each record consists of a set of fields and their corresponding values.
|
|
206
|
+
* * the 'types' section describes the corresponding data types that a record field has.
|
|
207
|
+
* * the 'metadata' section contains information about the query like 'analysisTimeframe', 'timezone' or 'locale'.
|
|
208
|
+
*
|
|
209
|
+
* Every record has an implicit 'index' according to the position in the 'records' JSON array.
|
|
210
|
+
* The types section has a list of 1..N possibhttps://dev.deus-dev.internal.dynatracelabs.com/query-frontend/docs/rest/swagger-ui/index.html?urls.primaryName=v0.5#/Query%20Execution/query%3Acancelle type 'buckets'. Each such bucket has an 'indexRange' which indicates which
|
|
211
|
+
* records will find their field types in which bucket. The index range has two values start & end and can be thought of as [startIndex, endIndex).
|
|
212
|
+
*
|
|
213
|
+
* A field part of a record with index 'i' will find its corresponding field type by first locating the bucket that satisfies:
|
|
214
|
+
*
|
|
215
|
+
* ```text
|
|
216
|
+
* startIndex <= i <= endIndex
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* Once the bucket is found the 'mappings' object has an entry for all the fields that are part of that record with index 'i'.
|
|
220
|
+
*
|
|
221
|
+
*
|
|
222
|
+
* Since enforcement of a particular schema is absent at ingestion time, it is possible to have records that share the same
|
|
223
|
+
* field name but their values are of a different type. This phenomenon will hence forth be named as a **"collision"**.
|
|
224
|
+
* When a collision does occur, we will create a new type 'bucket' that will have a different index range where
|
|
225
|
+
* the new record field types will be placed.
|
|
226
|
+
* It is guaranteed that every field of every record will have a corresponding type.
|
|
227
|
+
* **Clients should always take the included types into account when consuming records!**
|
|
228
|
+
*
|
|
229
|
+
*
|
|
230
|
+
* As an example, the following response highlights a collision, where a field called "cancelled" was ingested both as a
|
|
231
|
+
* boolean but also wrongly as a string. The first record contains the field "cancelled" as a string, but the very next record has the
|
|
232
|
+
* field with the same name but of boolean type. The types section has two entries. One corresponds to first record that has
|
|
233
|
+
* the field cancelled of type string. The second entry in the types section corresponds to the subsequent records which have
|
|
234
|
+
* the boolean field type.
|
|
235
|
+
*
|
|
236
|
+
* ```json
|
|
237
|
+
* {
|
|
238
|
+
* "state":"SUCCEEDED",
|
|
239
|
+
* "ttlSeconds":197,
|
|
240
|
+
* "result": {
|
|
241
|
+
* "records": [
|
|
242
|
+
* {
|
|
243
|
+
* "type": "user_event",
|
|
244
|
+
* "order_id": "1ea34-2515-1515-fe1g",
|
|
245
|
+
* "cancelled": "true"
|
|
246
|
+
* },
|
|
247
|
+
* {
|
|
248
|
+
* "type": "user_event",
|
|
249
|
+
* "order_id": "2ea34-2515-1515-fe1g",
|
|
250
|
+
* "cancelled": false
|
|
251
|
+
* },
|
|
252
|
+
* {
|
|
253
|
+
* "type": "user_event",
|
|
254
|
+
* "order_id": "3ea34-2515-1515-fe1g",
|
|
255
|
+
* "cancelled": true
|
|
256
|
+
* },
|
|
257
|
+
* {
|
|
258
|
+
* "type": "user_event",
|
|
259
|
+
* "order_id": "4ea34-2515-1515-fe1g",
|
|
260
|
+
* "cancelled": false
|
|
261
|
+
* }
|
|
262
|
+
* ],
|
|
263
|
+
* "types": [
|
|
264
|
+
* {
|
|
265
|
+
* "indexRange": [
|
|
266
|
+
* 0,
|
|
267
|
+
* 1
|
|
268
|
+
* ],
|
|
269
|
+
* "mappings": {
|
|
270
|
+
* "type": {
|
|
271
|
+
* "type": "string"
|
|
272
|
+
* },
|
|
273
|
+
* "order_id": {
|
|
274
|
+
* "type": "string"
|
|
275
|
+
* },
|
|
276
|
+
* "cancelled": {
|
|
277
|
+
* "type": "string"
|
|
278
|
+
* }
|
|
279
|
+
* }
|
|
280
|
+
* },
|
|
281
|
+
* {
|
|
282
|
+
* "indexRange": [
|
|
283
|
+
* 1,
|
|
284
|
+
* 4
|
|
285
|
+
* ],
|
|
286
|
+
* "mappings": {
|
|
287
|
+
* "type": {
|
|
288
|
+
* "type": "string"
|
|
289
|
+
* },
|
|
290
|
+
* "order_id": {
|
|
291
|
+
* "type": "string"
|
|
292
|
+
* },
|
|
293
|
+
* "cancelled": {
|
|
294
|
+
* "type": "boolean"
|
|
295
|
+
* }
|
|
296
|
+
* }
|
|
297
|
+
* }
|
|
298
|
+
* ],
|
|
299
|
+
* "metadata": {
|
|
300
|
+
* "query": "fetch events | ...",
|
|
301
|
+
* "dqlVersion": "V0_3",
|
|
302
|
+
* "appliedTimeframe": {
|
|
303
|
+
* "start": 1657624357056,
|
|
304
|
+
* "end": 1657631557056
|
|
305
|
+
* },
|
|
306
|
+
* "timezone": "Z",
|
|
307
|
+
* "locale": ""
|
|
308
|
+
* }
|
|
309
|
+
* }
|
|
310
|
+
* }
|
|
311
|
+
* ```
|
|
312
|
+
*
|
|
313
|
+
* ### Field data types
|
|
314
|
+
*
|
|
315
|
+
* The possible Grail types encountered in the "types" section is limited to a list of well-defined types:
|
|
316
|
+
* ```
|
|
317
|
+
* BOOLEAN
|
|
318
|
+
* STRING
|
|
319
|
+
* DOUBLE
|
|
320
|
+
* LONG
|
|
321
|
+
* TIMESTAMP
|
|
322
|
+
* TIMEFRAME
|
|
323
|
+
* DURATION
|
|
324
|
+
* BINARY
|
|
325
|
+
* IP_ADDRESS
|
|
326
|
+
* GEO_POINT
|
|
327
|
+
* ARRAY
|
|
328
|
+
* RECORD
|
|
329
|
+
* ```
|
|
330
|
+
* @returns The query already finished.
|
|
331
|
+
*/
|
|
332
|
+
queryCancel(config: {
|
|
333
|
+
/** The request-token of the query. */ requestToken: string;
|
|
334
|
+
abortSignal?: AbortSignal;
|
|
335
|
+
}): Promise<QueryPollResponse | void>;
|
|
336
|
+
}
|
|
337
|
+
export declare const queryExecutionClient: QueryExecutionClient;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ErrorType } from '@dynatrace-sdk/error-handlers';
|
|
2
|
+
/**
|
|
3
|
+
* Error base. All client errors should extend this class.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ApiClientError extends Error {
|
|
6
|
+
errorType: ErrorType;
|
|
7
|
+
constructor(name: string, message?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare function isApiClientError(e: any): e is ApiClientError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpClientResponse } from '@dynatrace-sdk/http-client';
|
|
2
|
+
import { ApiClientError } from './api-client-error';
|
|
3
|
+
export declare class ClientRequestError<DTO> extends ApiClientError {
|
|
4
|
+
body: DTO;
|
|
5
|
+
response: HttpClientResponse;
|
|
6
|
+
constructor(name: string, response: HttpClientResponse, body: DTO, message?: string);
|
|
7
|
+
}
|
|
8
|
+
export declare function isClientRequestError<DTO>(e: any): e is ClientRequestError<DTO>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ErrorEnvelope
|
|
3
|
+
*/
|
|
4
|
+
import { ClientRequestError } from './client-request-error';
|
|
5
|
+
import { ErrorEnvelope } from '../models';
|
|
6
|
+
export declare class ErrorEnvelopeError extends ClientRequestError<ErrorEnvelope> {
|
|
7
|
+
}
|
|
8
|
+
export declare function isErrorEnvelopeError(e: any): e is ErrorEnvelopeError;
|