@dynatrace-sdk/client-query 1.20.0 → 1.20.2
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 +14 -0
- package/README.md +2 -2
- package/cjs/index.js +116 -61
- package/dynatrace-metadata.json +2 -3
- package/esm/index.js +116 -61
- package/package.json +1 -1
- package/types/packages/client/query/src/lib/utils/transformations.d.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
@dynatrace-sdk/client-query
|
|
4
4
|
|
|
5
|
+
## 1.20.2
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- Improve performance of date transformations. (APPDEV-12840)
|
|
10
|
+
|
|
11
|
+
## 1.20.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Improve performance of payload transformations. (APPDEV-12840)
|
|
16
|
+
- Remove generatedAt property from metadata file. (APPDEV-12696)
|
|
17
|
+
|
|
5
18
|
## 1.20.0
|
|
6
19
|
|
|
7
20
|
### Minor changes
|
|
21
|
+
|
|
8
22
|
- Add request body parameter `includeTypes` to `ExecuteRequest`
|
|
9
23
|
- Add header `dt-client-context` to all query endpoints
|
|
10
24
|
- Add `enforce-query-consumption-limit` header to `/query:execute` and `/query:autocomplete` endpoints
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @dynatrace-sdk/client-query
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@dynatrace-sdk/client-query/v/1.20.2)
|
|
4
4
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
5
5
|
|
|
6
6
|
Exposes an API to fetch records stored in Grail
|
|
@@ -528,7 +528,7 @@ It is guaranteed that every field of every record will have a corresponding type
|
|
|
528
528
|
|
|
529
529
|
| Return type | Description |
|
|
530
530
|
|---|---|
|
|
531
|
-
|Promise<QueryPollResponse
|
|
531
|
+
|Promise<QueryPollResponse \| void>|The query already finished.|
|
|
532
532
|
|
|
533
533
|
|
|
534
534
|
#### Throws
|
package/cjs/index.js
CHANGED
|
@@ -123,49 +123,93 @@ function mergeKeys(key1, key2) {
|
|
|
123
123
|
return key1;
|
|
124
124
|
return `${key1}.${key2}`;
|
|
125
125
|
}
|
|
126
|
-
function matchKey(key,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
function matchKey(key, rules, cache) {
|
|
127
|
+
if (cache.has(key)) {
|
|
128
|
+
return cache.get(key);
|
|
129
|
+
}
|
|
130
|
+
for (const rule of rules) {
|
|
131
|
+
const pattern = Array.isArray(rule) ? rule[0] : rule;
|
|
132
|
+
const config = Array.isArray(rule) ? rule[1] : defaultRuleConfig;
|
|
133
|
+
if (key === pattern) {
|
|
134
|
+
const result = [pattern, config];
|
|
135
|
+
cache.set(key, result);
|
|
136
|
+
return result;
|
|
131
137
|
}
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
let i = 0;
|
|
139
|
+
let j = 0;
|
|
140
|
+
const keyLen = key.length;
|
|
141
|
+
const patternLen = pattern.length;
|
|
142
|
+
let isMatch = true;
|
|
143
|
+
while (i < keyLen && j < patternLen) {
|
|
144
|
+
let keyPartEnd = key.indexOf(".", i);
|
|
145
|
+
let patternPartEnd = pattern.indexOf(".", j);
|
|
146
|
+
if (keyPartEnd === -1)
|
|
147
|
+
keyPartEnd = keyLen;
|
|
148
|
+
if (patternPartEnd === -1)
|
|
149
|
+
patternPartEnd = patternLen;
|
|
150
|
+
const keyPart = key.slice(i, keyPartEnd);
|
|
151
|
+
const patternPart = pattern.slice(j, patternPartEnd);
|
|
152
|
+
if (patternPart !== "*" && patternPart !== "**" && keyPart !== patternPart) {
|
|
153
|
+
isMatch = false;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
i = keyPartEnd + 1;
|
|
157
|
+
j = patternPartEnd + 1;
|
|
134
158
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (keyPart !== ruleKeyParts[idx] && !wildcard) {
|
|
141
|
-
if (ruleKeyParts[idx] === "**") {
|
|
142
|
-
wildcard = true;
|
|
143
|
-
} else if (ruleKeyParts[idx] === "*") {
|
|
144
|
-
wildcard = true;
|
|
145
|
-
} else {
|
|
146
|
-
matchResult = false;
|
|
159
|
+
if (isMatch) {
|
|
160
|
+
if (j < patternLen) {
|
|
161
|
+
const remaining = pattern.slice(j);
|
|
162
|
+
if (remaining !== "**" && remaining !== "*") {
|
|
163
|
+
isMatch = false;
|
|
147
164
|
}
|
|
148
165
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
keyPartsReversed.forEach((keyPart, idx) => {
|
|
152
|
-
if (keyPart !== ruleKeyPartsReversed[idx] && !wildcard) {
|
|
153
|
-
if (ruleKeyPartsReversed[idx] === "**") {
|
|
154
|
-
wildcard = true;
|
|
155
|
-
} else if (ruleKeyPartsReversed[idx] === "*") {
|
|
156
|
-
wildcard = true;
|
|
157
|
-
} else {
|
|
158
|
-
matchResult = false;
|
|
159
|
-
}
|
|
166
|
+
if (i < keyLen && pattern.slice(j - 1) !== "**") {
|
|
167
|
+
isMatch = false;
|
|
160
168
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
}
|
|
170
|
+
if (isMatch) {
|
|
171
|
+
const result = [pattern, config];
|
|
172
|
+
cache.set(key, result);
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
166
175
|
}
|
|
176
|
+
cache.set(key, null);
|
|
167
177
|
return null;
|
|
168
178
|
}
|
|
179
|
+
var potentialMatchForRoot = (pattern, key) => pattern.startsWith(key) || pattern.startsWith("*") || pattern.startsWith("**");
|
|
180
|
+
var potentialMatch = (pattern, key) => pattern.startsWith(key) || pattern.includes("*") || pattern.includes("**");
|
|
181
|
+
function partialMatch(key, keyPatterns) {
|
|
182
|
+
const keyPatternsLen = keyPatterns.length;
|
|
183
|
+
if (!key.includes(".")) {
|
|
184
|
+
for (let i = 0; i < keyPatternsLen; i++) {
|
|
185
|
+
const pattern = keyPatterns[i];
|
|
186
|
+
if (potentialMatchForRoot(pattern, key))
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
let dotIndex = -1;
|
|
192
|
+
let currentKeyEnd = 0;
|
|
193
|
+
while ((dotIndex = key.indexOf(".", currentKeyEnd)) !== -1) {
|
|
194
|
+
const currentKey = key.slice(0, dotIndex);
|
|
195
|
+
const isRoot = !currentKey.includes(".");
|
|
196
|
+
for (let i = 0; i < keyPatternsLen; i++) {
|
|
197
|
+
const pattern = keyPatterns[i];
|
|
198
|
+
if (isRoot) {
|
|
199
|
+
if (potentialMatchForRoot(pattern, currentKey))
|
|
200
|
+
return true;
|
|
201
|
+
} else if (potentialMatch(pattern, currentKey))
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
currentKeyEnd = dotIndex + 1;
|
|
205
|
+
}
|
|
206
|
+
for (let i = 0; i < keyPatternsLen; i++) {
|
|
207
|
+
const pattern = keyPatterns[i];
|
|
208
|
+
if (potentialMatch(pattern, key))
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
169
213
|
var dateTimePattern = /^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[+-]\d{2}:\d{2})?)$/i;
|
|
170
214
|
function isDateLike(value) {
|
|
171
215
|
if (typeof value === "string") {
|
|
@@ -184,37 +228,48 @@ function transformValue(value, rules, direction) {
|
|
|
184
228
|
}
|
|
185
229
|
return value;
|
|
186
230
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
231
|
+
function walk(obj, direction, rules, rulesCache, keyPatterns, currentKey = "") {
|
|
232
|
+
if (rules.length <= 0) {
|
|
233
|
+
return obj;
|
|
234
|
+
}
|
|
235
|
+
if (!partialMatch(currentKey, keyPatterns)) {
|
|
236
|
+
return obj;
|
|
237
|
+
}
|
|
238
|
+
if (Array.isArray(obj)) {
|
|
239
|
+
const match = matchKey(currentKey, rules, rulesCache);
|
|
240
|
+
obj.forEach((item, idx) => {
|
|
241
|
+
if (typeof item === "object" && item !== null) {
|
|
242
|
+
walk(item, direction, rules, rulesCache, keyPatterns, currentKey);
|
|
243
|
+
} else if (match) {
|
|
244
|
+
obj[idx] = transformValue(obj[idx], match[1], direction);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
if (typeof obj === "object" && obj !== null && !Array.isArray(obj)) {
|
|
249
|
+
for (const key of Object.keys(obj)) {
|
|
250
|
+
const mergedKey = mergeKeys(currentKey, key);
|
|
251
|
+
const match = matchKey(mergedKey, rules, rulesCache);
|
|
252
|
+
if (match) {
|
|
253
|
+
obj[key] = transformValue(obj[key], match[1], direction);
|
|
207
254
|
}
|
|
255
|
+
walk(obj[key], direction, rules, rulesCache, keyPatterns, mergedKey);
|
|
208
256
|
}
|
|
209
|
-
return obj;
|
|
210
257
|
}
|
|
211
|
-
return
|
|
258
|
+
return obj;
|
|
259
|
+
}
|
|
260
|
+
function flattenKeyPatterns(keyPatterns) {
|
|
261
|
+
return keyPatterns.map((k) => Array.isArray(k) ? k[0] : k);
|
|
262
|
+
}
|
|
263
|
+
function transform(direction, object, rules) {
|
|
264
|
+
const flatKeyPatterns = flattenKeyPatterns(rules);
|
|
265
|
+
const rulesCache = /* @__PURE__ */ new Map();
|
|
266
|
+
return walk(object, direction, rules, rulesCache, flatKeyPatterns);
|
|
212
267
|
}
|
|
213
|
-
function transformRequest(object,
|
|
214
|
-
return transform("from", object,
|
|
268
|
+
function transformRequest(object, rules) {
|
|
269
|
+
return transform("from", object, rules);
|
|
215
270
|
}
|
|
216
|
-
function transformResponse(object,
|
|
217
|
-
return transform("to", object,
|
|
271
|
+
function transformResponse(object, rules) {
|
|
272
|
+
return transform("to", object, rules);
|
|
218
273
|
}
|
|
219
274
|
|
|
220
275
|
// packages/client/query/src/lib/apis/query-assistance-api.ts
|
package/dynatrace-metadata.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dynagen": {
|
|
3
|
-
"version": "0.
|
|
4
|
-
"generatedAt": "2025-03-31T11:21:40.514Z",
|
|
3
|
+
"version": "0.19.2",
|
|
5
4
|
"template": {
|
|
6
5
|
"name": "@dynatrace-sdk/template-typescript-client",
|
|
7
|
-
"version": "0.33.
|
|
6
|
+
"version": "0.33.7"
|
|
8
7
|
},
|
|
9
8
|
"featureFlags": {
|
|
10
9
|
"typeguards": true
|
package/esm/index.js
CHANGED
|
@@ -88,49 +88,93 @@ function mergeKeys(key1, key2) {
|
|
|
88
88
|
return key1;
|
|
89
89
|
return `${key1}.${key2}`;
|
|
90
90
|
}
|
|
91
|
-
function matchKey(key,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
function matchKey(key, rules, cache) {
|
|
92
|
+
if (cache.has(key)) {
|
|
93
|
+
return cache.get(key);
|
|
94
|
+
}
|
|
95
|
+
for (const rule of rules) {
|
|
96
|
+
const pattern = Array.isArray(rule) ? rule[0] : rule;
|
|
97
|
+
const config = Array.isArray(rule) ? rule[1] : defaultRuleConfig;
|
|
98
|
+
if (key === pattern) {
|
|
99
|
+
const result = [pattern, config];
|
|
100
|
+
cache.set(key, result);
|
|
101
|
+
return result;
|
|
96
102
|
}
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
let i = 0;
|
|
104
|
+
let j = 0;
|
|
105
|
+
const keyLen = key.length;
|
|
106
|
+
const patternLen = pattern.length;
|
|
107
|
+
let isMatch = true;
|
|
108
|
+
while (i < keyLen && j < patternLen) {
|
|
109
|
+
let keyPartEnd = key.indexOf(".", i);
|
|
110
|
+
let patternPartEnd = pattern.indexOf(".", j);
|
|
111
|
+
if (keyPartEnd === -1)
|
|
112
|
+
keyPartEnd = keyLen;
|
|
113
|
+
if (patternPartEnd === -1)
|
|
114
|
+
patternPartEnd = patternLen;
|
|
115
|
+
const keyPart = key.slice(i, keyPartEnd);
|
|
116
|
+
const patternPart = pattern.slice(j, patternPartEnd);
|
|
117
|
+
if (patternPart !== "*" && patternPart !== "**" && keyPart !== patternPart) {
|
|
118
|
+
isMatch = false;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
i = keyPartEnd + 1;
|
|
122
|
+
j = patternPartEnd + 1;
|
|
99
123
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (keyPart !== ruleKeyParts[idx] && !wildcard) {
|
|
106
|
-
if (ruleKeyParts[idx] === "**") {
|
|
107
|
-
wildcard = true;
|
|
108
|
-
} else if (ruleKeyParts[idx] === "*") {
|
|
109
|
-
wildcard = true;
|
|
110
|
-
} else {
|
|
111
|
-
matchResult = false;
|
|
124
|
+
if (isMatch) {
|
|
125
|
+
if (j < patternLen) {
|
|
126
|
+
const remaining = pattern.slice(j);
|
|
127
|
+
if (remaining !== "**" && remaining !== "*") {
|
|
128
|
+
isMatch = false;
|
|
112
129
|
}
|
|
113
130
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
keyPartsReversed.forEach((keyPart, idx) => {
|
|
117
|
-
if (keyPart !== ruleKeyPartsReversed[idx] && !wildcard) {
|
|
118
|
-
if (ruleKeyPartsReversed[idx] === "**") {
|
|
119
|
-
wildcard = true;
|
|
120
|
-
} else if (ruleKeyPartsReversed[idx] === "*") {
|
|
121
|
-
wildcard = true;
|
|
122
|
-
} else {
|
|
123
|
-
matchResult = false;
|
|
124
|
-
}
|
|
131
|
+
if (i < keyLen && pattern.slice(j - 1) !== "**") {
|
|
132
|
+
isMatch = false;
|
|
125
133
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
}
|
|
135
|
+
if (isMatch) {
|
|
136
|
+
const result = [pattern, config];
|
|
137
|
+
cache.set(key, result);
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
131
140
|
}
|
|
141
|
+
cache.set(key, null);
|
|
132
142
|
return null;
|
|
133
143
|
}
|
|
144
|
+
var potentialMatchForRoot = (pattern, key) => pattern.startsWith(key) || pattern.startsWith("*") || pattern.startsWith("**");
|
|
145
|
+
var potentialMatch = (pattern, key) => pattern.startsWith(key) || pattern.includes("*") || pattern.includes("**");
|
|
146
|
+
function partialMatch(key, keyPatterns) {
|
|
147
|
+
const keyPatternsLen = keyPatterns.length;
|
|
148
|
+
if (!key.includes(".")) {
|
|
149
|
+
for (let i = 0; i < keyPatternsLen; i++) {
|
|
150
|
+
const pattern = keyPatterns[i];
|
|
151
|
+
if (potentialMatchForRoot(pattern, key))
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
let dotIndex = -1;
|
|
157
|
+
let currentKeyEnd = 0;
|
|
158
|
+
while ((dotIndex = key.indexOf(".", currentKeyEnd)) !== -1) {
|
|
159
|
+
const currentKey = key.slice(0, dotIndex);
|
|
160
|
+
const isRoot = !currentKey.includes(".");
|
|
161
|
+
for (let i = 0; i < keyPatternsLen; i++) {
|
|
162
|
+
const pattern = keyPatterns[i];
|
|
163
|
+
if (isRoot) {
|
|
164
|
+
if (potentialMatchForRoot(pattern, currentKey))
|
|
165
|
+
return true;
|
|
166
|
+
} else if (potentialMatch(pattern, currentKey))
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
currentKeyEnd = dotIndex + 1;
|
|
170
|
+
}
|
|
171
|
+
for (let i = 0; i < keyPatternsLen; i++) {
|
|
172
|
+
const pattern = keyPatterns[i];
|
|
173
|
+
if (potentialMatch(pattern, key))
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
134
178
|
var dateTimePattern = /^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[+-]\d{2}:\d{2})?)$/i;
|
|
135
179
|
function isDateLike(value) {
|
|
136
180
|
if (typeof value === "string") {
|
|
@@ -149,37 +193,48 @@ function transformValue(value, rules, direction) {
|
|
|
149
193
|
}
|
|
150
194
|
return value;
|
|
151
195
|
}
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
196
|
+
function walk(obj, direction, rules, rulesCache, keyPatterns, currentKey = "") {
|
|
197
|
+
if (rules.length <= 0) {
|
|
198
|
+
return obj;
|
|
199
|
+
}
|
|
200
|
+
if (!partialMatch(currentKey, keyPatterns)) {
|
|
201
|
+
return obj;
|
|
202
|
+
}
|
|
203
|
+
if (Array.isArray(obj)) {
|
|
204
|
+
const match = matchKey(currentKey, rules, rulesCache);
|
|
205
|
+
obj.forEach((item, idx) => {
|
|
206
|
+
if (typeof item === "object" && item !== null) {
|
|
207
|
+
walk(item, direction, rules, rulesCache, keyPatterns, currentKey);
|
|
208
|
+
} else if (match) {
|
|
209
|
+
obj[idx] = transformValue(obj[idx], match[1], direction);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (typeof obj === "object" && obj !== null && !Array.isArray(obj)) {
|
|
214
|
+
for (const key of Object.keys(obj)) {
|
|
215
|
+
const mergedKey = mergeKeys(currentKey, key);
|
|
216
|
+
const match = matchKey(mergedKey, rules, rulesCache);
|
|
217
|
+
if (match) {
|
|
218
|
+
obj[key] = transformValue(obj[key], match[1], direction);
|
|
172
219
|
}
|
|
220
|
+
walk(obj[key], direction, rules, rulesCache, keyPatterns, mergedKey);
|
|
173
221
|
}
|
|
174
|
-
return obj;
|
|
175
222
|
}
|
|
176
|
-
return
|
|
223
|
+
return obj;
|
|
224
|
+
}
|
|
225
|
+
function flattenKeyPatterns(keyPatterns) {
|
|
226
|
+
return keyPatterns.map((k) => Array.isArray(k) ? k[0] : k);
|
|
227
|
+
}
|
|
228
|
+
function transform(direction, object, rules) {
|
|
229
|
+
const flatKeyPatterns = flattenKeyPatterns(rules);
|
|
230
|
+
const rulesCache = /* @__PURE__ */ new Map();
|
|
231
|
+
return walk(object, direction, rules, rulesCache, flatKeyPatterns);
|
|
177
232
|
}
|
|
178
|
-
function transformRequest(object,
|
|
179
|
-
return transform("from", object,
|
|
233
|
+
function transformRequest(object, rules) {
|
|
234
|
+
return transform("from", object, rules);
|
|
180
235
|
}
|
|
181
|
-
function transformResponse(object,
|
|
182
|
-
return transform("to", object,
|
|
236
|
+
function transformResponse(object, rules) {
|
|
237
|
+
return transform("to", object, rules);
|
|
183
238
|
}
|
|
184
239
|
|
|
185
240
|
// packages/client/query/src/lib/apis/query-assistance-api.ts
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ type TransformRuleConfig = {
|
|
|
2
2
|
force?: boolean;
|
|
3
3
|
datetime?: boolean;
|
|
4
4
|
};
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
5
|
+
type TransformRulesParam = Array<string | [string, TransformRuleConfig]>;
|
|
6
|
+
export declare function transformRequest<T = any>(object: T, rules: TransformRulesParam): T;
|
|
7
|
+
export declare function transformResponse<T = any>(object: T, rules: TransformRulesParam): T;
|
|
7
8
|
export {};
|