@dynatrace-sdk/client-classic-environment-v2 3.7.0 → 3.7.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 -1
- package/README.md +1 -1
- package/cjs/index.js +117 -62
- package/dynatrace-metadata.json +2 -3
- package/esm/index.js +117 -62
- package/package.json +1 -1
- package/types/packages/client/classic-environment-v2/src/lib/utils/transformations.d.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
@dynatrace-sdk/client-classic-environment-v2
|
|
4
4
|
|
|
5
|
+
## 3.7.2
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- Improve performance of date transformations. (APPDEV-12840)
|
|
10
|
+
|
|
11
|
+
## 3.7.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
|
## 3.7.0
|
|
6
19
|
|
|
7
20
|
### Minor Changes
|
|
8
21
|
|
|
9
22
|
- Fix `getPermissions` operation success response to return proper `AccessorPermissionsList` type instead of `AccessorPermissionsList[]` in **SettingsObjectsAPI**
|
|
10
|
-
- Add new `DEBUGGING` value
|
|
23
|
+
- Add new `DEBUGGING` value to `ActiveGateModule.type` enum
|
|
11
24
|
- Add new optional fields (`description`, `displayName`, `isRecommended`) to the `FeatureSetDetails` model
|
|
12
25
|
- Add new optional `browserExecutionSupported` field to the `PrivateSyntheticLocation` and `SyntheticPrivateLocationUpdate` models
|
|
13
26
|
- Made `targetList` field optional in `SyntheticMultiProtocolMonitorStepDto`
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @dynatrace-sdk/client-classic-environment-v2
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@dynatrace-sdk/client-classic-environment-v2/v/3.7.2)
|
|
4
4
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
5
5
|
|
|
6
6
|
|
package/cjs/index.js
CHANGED
|
@@ -389,49 +389,93 @@ function mergeKeys(key1, key2) {
|
|
|
389
389
|
return key1;
|
|
390
390
|
return `${key1}.${key2}`;
|
|
391
391
|
}
|
|
392
|
-
function matchKey(key,
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
392
|
+
function matchKey(key, rules, cache) {
|
|
393
|
+
if (cache.has(key)) {
|
|
394
|
+
return cache.get(key);
|
|
395
|
+
}
|
|
396
|
+
for (const rule of rules) {
|
|
397
|
+
const pattern = Array.isArray(rule) ? rule[0] : rule;
|
|
398
|
+
const config = Array.isArray(rule) ? rule[1] : defaultRuleConfig;
|
|
399
|
+
if (key === pattern) {
|
|
400
|
+
const result = [pattern, config];
|
|
401
|
+
cache.set(key, result);
|
|
402
|
+
return result;
|
|
403
|
+
}
|
|
404
|
+
let i = 0;
|
|
405
|
+
let j = 0;
|
|
406
|
+
const keyLen = key.length;
|
|
407
|
+
const patternLen = pattern.length;
|
|
408
|
+
let isMatch = true;
|
|
409
|
+
while (i < keyLen && j < patternLen) {
|
|
410
|
+
let keyPartEnd = key.indexOf(".", i);
|
|
411
|
+
let patternPartEnd = pattern.indexOf(".", j);
|
|
412
|
+
if (keyPartEnd === -1)
|
|
413
|
+
keyPartEnd = keyLen;
|
|
414
|
+
if (patternPartEnd === -1)
|
|
415
|
+
patternPartEnd = patternLen;
|
|
416
|
+
const keyPart = key.slice(i, keyPartEnd);
|
|
417
|
+
const patternPart = pattern.slice(j, patternPartEnd);
|
|
418
|
+
if (patternPart !== "*" && patternPart !== "**" && keyPart !== patternPart) {
|
|
419
|
+
isMatch = false;
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
i = keyPartEnd + 1;
|
|
423
|
+
j = patternPartEnd + 1;
|
|
400
424
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (keyPart !== ruleKeyParts[idx] && !wildcard) {
|
|
407
|
-
if (ruleKeyParts[idx] === "**") {
|
|
408
|
-
wildcard = true;
|
|
409
|
-
} else if (ruleKeyParts[idx] === "*") {
|
|
410
|
-
wildcard = true;
|
|
411
|
-
} else {
|
|
412
|
-
matchResult = false;
|
|
425
|
+
if (isMatch) {
|
|
426
|
+
if (j < patternLen) {
|
|
427
|
+
const remaining = pattern.slice(j);
|
|
428
|
+
if (remaining !== "**" && remaining !== "*") {
|
|
429
|
+
isMatch = false;
|
|
413
430
|
}
|
|
414
431
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
keyPartsReversed.forEach((keyPart, idx) => {
|
|
418
|
-
if (keyPart !== ruleKeyPartsReversed[idx] && !wildcard) {
|
|
419
|
-
if (ruleKeyPartsReversed[idx] === "**") {
|
|
420
|
-
wildcard = true;
|
|
421
|
-
} else if (ruleKeyPartsReversed[idx] === "*") {
|
|
422
|
-
wildcard = true;
|
|
423
|
-
} else {
|
|
424
|
-
matchResult = false;
|
|
425
|
-
}
|
|
432
|
+
if (i < keyLen && pattern.slice(j - 1) !== "**") {
|
|
433
|
+
isMatch = false;
|
|
426
434
|
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
435
|
+
}
|
|
436
|
+
if (isMatch) {
|
|
437
|
+
const result = [pattern, config];
|
|
438
|
+
cache.set(key, result);
|
|
439
|
+
return result;
|
|
440
|
+
}
|
|
432
441
|
}
|
|
442
|
+
cache.set(key, null);
|
|
433
443
|
return null;
|
|
434
444
|
}
|
|
445
|
+
var potentialMatchForRoot = (pattern, key) => pattern.startsWith(key) || pattern.startsWith("*") || pattern.startsWith("**");
|
|
446
|
+
var potentialMatch = (pattern, key) => pattern.startsWith(key) || pattern.includes("*") || pattern.includes("**");
|
|
447
|
+
function partialMatch(key, keyPatterns) {
|
|
448
|
+
const keyPatternsLen = keyPatterns.length;
|
|
449
|
+
if (!key.includes(".")) {
|
|
450
|
+
for (let i = 0; i < keyPatternsLen; i++) {
|
|
451
|
+
const pattern = keyPatterns[i];
|
|
452
|
+
if (potentialMatchForRoot(pattern, key))
|
|
453
|
+
return true;
|
|
454
|
+
}
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
let dotIndex = -1;
|
|
458
|
+
let currentKeyEnd = 0;
|
|
459
|
+
while ((dotIndex = key.indexOf(".", currentKeyEnd)) !== -1) {
|
|
460
|
+
const currentKey = key.slice(0, dotIndex);
|
|
461
|
+
const isRoot = !currentKey.includes(".");
|
|
462
|
+
for (let i = 0; i < keyPatternsLen; i++) {
|
|
463
|
+
const pattern = keyPatterns[i];
|
|
464
|
+
if (isRoot) {
|
|
465
|
+
if (potentialMatchForRoot(pattern, currentKey))
|
|
466
|
+
return true;
|
|
467
|
+
} else if (potentialMatch(pattern, currentKey))
|
|
468
|
+
return true;
|
|
469
|
+
}
|
|
470
|
+
currentKeyEnd = dotIndex + 1;
|
|
471
|
+
}
|
|
472
|
+
for (let i = 0; i < keyPatternsLen; i++) {
|
|
473
|
+
const pattern = keyPatterns[i];
|
|
474
|
+
if (potentialMatch(pattern, key))
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
435
479
|
var dateTimePattern = /^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[+-]\d{2}:\d{2})?)$/i;
|
|
436
480
|
function isDateLike(value) {
|
|
437
481
|
if (typeof value === "string") {
|
|
@@ -450,37 +494,48 @@ function transformValue(value, rules, direction) {
|
|
|
450
494
|
}
|
|
451
495
|
return value;
|
|
452
496
|
}
|
|
453
|
-
function
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
497
|
+
function walk(obj, direction, rules, rulesCache, keyPatterns, currentKey = "") {
|
|
498
|
+
if (rules.length <= 0) {
|
|
499
|
+
return obj;
|
|
500
|
+
}
|
|
501
|
+
if (!partialMatch(currentKey, keyPatterns)) {
|
|
502
|
+
return obj;
|
|
503
|
+
}
|
|
504
|
+
if (Array.isArray(obj)) {
|
|
505
|
+
const match = matchKey(currentKey, rules, rulesCache);
|
|
506
|
+
obj.forEach((item, idx) => {
|
|
507
|
+
if (typeof item === "object" && item !== null) {
|
|
508
|
+
walk(item, direction, rules, rulesCache, keyPatterns, currentKey);
|
|
509
|
+
} else if (match) {
|
|
510
|
+
obj[idx] = transformValue(obj[idx], match[1], direction);
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
if (typeof obj === "object" && obj !== null && !Array.isArray(obj)) {
|
|
515
|
+
for (const key of Object.keys(obj)) {
|
|
516
|
+
const mergedKey = mergeKeys(currentKey, key);
|
|
517
|
+
const match = matchKey(mergedKey, rules, rulesCache);
|
|
518
|
+
if (match) {
|
|
519
|
+
obj[key] = transformValue(obj[key], match[1], direction);
|
|
473
520
|
}
|
|
521
|
+
walk(obj[key], direction, rules, rulesCache, keyPatterns, mergedKey);
|
|
474
522
|
}
|
|
475
|
-
return obj;
|
|
476
523
|
}
|
|
477
|
-
return
|
|
524
|
+
return obj;
|
|
525
|
+
}
|
|
526
|
+
function flattenKeyPatterns(keyPatterns) {
|
|
527
|
+
return keyPatterns.map((k) => Array.isArray(k) ? k[0] : k);
|
|
528
|
+
}
|
|
529
|
+
function transform(direction, object, rules) {
|
|
530
|
+
const flatKeyPatterns = flattenKeyPatterns(rules);
|
|
531
|
+
const rulesCache = /* @__PURE__ */ new Map();
|
|
532
|
+
return walk(object, direction, rules, rulesCache, flatKeyPatterns);
|
|
478
533
|
}
|
|
479
|
-
function transformRequest(object,
|
|
480
|
-
return transform("from", object,
|
|
534
|
+
function transformRequest(object, rules) {
|
|
535
|
+
return transform("from", object, rules);
|
|
481
536
|
}
|
|
482
|
-
function transformResponse(object,
|
|
483
|
-
return transform("to", object,
|
|
537
|
+
function transformResponse(object, rules) {
|
|
538
|
+
return transform("to", object, rules);
|
|
484
539
|
}
|
|
485
540
|
|
|
486
541
|
// packages/client/classic-environment-v2/src/lib/utils/url-helpers.ts
|
package/dynatrace-metadata.json
CHANGED
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
function matchKey(key, rules, cache) {
|
|
92
|
+
if (cache.has(key)) {
|
|
93
|
+
return cache.get(key);
|
|
94
|
+
}
|
|
95
|
+
for (const rule of rules) {
|
|
96
|
+
const pattern = Array.isArray(rule) ? rule[0] : rule;
|
|
97
|
+
const config = Array.isArray(rule) ? rule[1] : defaultRuleConfig;
|
|
98
|
+
if (key === pattern) {
|
|
99
|
+
const result = [pattern, config];
|
|
100
|
+
cache.set(key, result);
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
let i = 0;
|
|
104
|
+
let j = 0;
|
|
105
|
+
const keyLen = key.length;
|
|
106
|
+
const patternLen = pattern.length;
|
|
107
|
+
let isMatch = true;
|
|
108
|
+
while (i < keyLen && j < patternLen) {
|
|
109
|
+
let keyPartEnd = key.indexOf(".", i);
|
|
110
|
+
let patternPartEnd = pattern.indexOf(".", j);
|
|
111
|
+
if (keyPartEnd === -1)
|
|
112
|
+
keyPartEnd = keyLen;
|
|
113
|
+
if (patternPartEnd === -1)
|
|
114
|
+
patternPartEnd = patternLen;
|
|
115
|
+
const keyPart = key.slice(i, keyPartEnd);
|
|
116
|
+
const patternPart = pattern.slice(j, patternPartEnd);
|
|
117
|
+
if (patternPart !== "*" && patternPart !== "**" && keyPart !== patternPart) {
|
|
118
|
+
isMatch = false;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
i = keyPartEnd + 1;
|
|
122
|
+
j = patternPartEnd + 1;
|
|
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/classic-environment-v2/src/lib/utils/url-helpers.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 {};
|