@dynatrace-sdk/client-query 1.5.0 → 1.7.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 +25 -0
- package/README.md +1 -1
- package/cjs/index.js +696 -528
- package/docs/DOCS.md +7 -6
- package/dynatrace-metadata.json +3 -3
- package/esm/index.js +704 -530
- package/package.json +1 -1
- package/types/packages/client/query/src/lib/apis/query-assistance-api.d.ts +1 -1
- package/types/packages/client/query/src/lib/apis/query-execution-api.d.ts +2 -1
- package/types/packages/client/query/src/lib/error-envelopes/api-client-error.d.ts +2 -1
- package/types/packages/client/query/src/lib/error-envelopes/client-request-error.d.ts +1 -1
- package/types/packages/client/query/src/lib/models/field-type-type.d.ts +1 -0
- package/types/packages/client/query/src/lib/models/token-type.d.ts +2 -1
- package/types/packages/http-client/src/index.d.ts +1 -1
- package/types/packages/http-client/src/lib/platform/http-client-response-error.d.ts +4 -1
- package/types/packages/http-client/src/lib/types/http-client-abort-error.d.ts +1 -0
- package/types/packages/http-client/src/lib/types/http-client-network-error.d.ts +1 -0
- package/types/packages/http-client/src/lib/types/http-client-request-error.d.ts +1 -0
- package/types/packages/http-client/src/lib/types/http-client-response-error.d.ts +1 -0
- package/types/packages/platform/error-handlers/src/lib/types/common-serialized-error.d.ts +2 -0
- package/types/packages/platform/error-handlers/src/lib/types/http-serialized-error.d.ts +3 -0
package/esm/index.js
CHANGED
|
@@ -20,7 +20,10 @@ var __export = (target, all) => {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
// packages/client/query/src/lib/apis/query-assistance-api.ts
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
httpClient as defaultHttpClient,
|
|
25
|
+
isHttpClientResponseError
|
|
26
|
+
} from "@dynatrace-sdk/http-client";
|
|
24
27
|
|
|
25
28
|
// packages/platform/shared/utils/get-global-with-dt-runtime.ts
|
|
26
29
|
var getGlobalWithDtRuntime = () => typeof globalThis !== "undefined" ? globalThis : window;
|
|
@@ -43,11 +46,12 @@ function getAddGlobalErrorSerializer() {
|
|
|
43
46
|
|
|
44
47
|
// packages/client/query/src/lib/error-envelopes/api-client-error.ts
|
|
45
48
|
var ApiClientError = class extends Error {
|
|
46
|
-
|
|
47
|
-
constructor(name, message) {
|
|
49
|
+
constructor(name, message, cause) {
|
|
48
50
|
super(message);
|
|
51
|
+
this.cause = cause;
|
|
49
52
|
this.name = name;
|
|
50
53
|
}
|
|
54
|
+
errorType = "JS Error" /* COMMON */;
|
|
51
55
|
};
|
|
52
56
|
function isApiClientError(e) {
|
|
53
57
|
return e instanceof ApiClientError;
|
|
@@ -57,8 +61,8 @@ function isApiClientError(e) {
|
|
|
57
61
|
var ClientRequestError = class extends ApiClientError {
|
|
58
62
|
body;
|
|
59
63
|
response;
|
|
60
|
-
constructor(name, response, body, message) {
|
|
61
|
-
super(name, message);
|
|
64
|
+
constructor(name, response, body, message, cause) {
|
|
65
|
+
super(name, message, cause);
|
|
62
66
|
this.errorType = "Http Error" /* HTTP */;
|
|
63
67
|
this.body = body;
|
|
64
68
|
this.response = response;
|
|
@@ -87,6 +91,7 @@ var apiClientErrorSerializer = async (error) => {
|
|
|
87
91
|
stack: error.stack,
|
|
88
92
|
type: "Http Error" /* HTTP */,
|
|
89
93
|
body: error.body,
|
|
94
|
+
cause: error.cause,
|
|
90
95
|
...getOptionalErrorRef(error.body)
|
|
91
96
|
};
|
|
92
97
|
} else if (isApiClientError(error)) {
|
|
@@ -94,7 +99,8 @@ var apiClientErrorSerializer = async (error) => {
|
|
|
94
99
|
name: error.name,
|
|
95
100
|
message: error.message,
|
|
96
101
|
stack: error.stack,
|
|
97
|
-
type: "JS Error" /* COMMON
|
|
102
|
+
type: "JS Error" /* COMMON */,
|
|
103
|
+
cause: error.cause
|
|
98
104
|
};
|
|
99
105
|
}
|
|
100
106
|
};
|
|
@@ -113,15 +119,23 @@ function getOptionalErrorRef(body) {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
// packages/client/query/src/lib/error-envelopes/get-error-message.ts
|
|
122
|
+
function serializeData(data) {
|
|
123
|
+
try {
|
|
124
|
+
return JSON.stringify(data);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
return String(data);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
116
129
|
function getMessagesFromErrorDetails(details) {
|
|
117
130
|
const messages = [];
|
|
118
131
|
Object.entries(details).forEach(([name, data]) => {
|
|
132
|
+
const serializedData = serializeData(data);
|
|
119
133
|
switch (name) {
|
|
120
134
|
case "missingScopes":
|
|
121
|
-
messages.push(`Missing scopes: ${
|
|
135
|
+
messages.push(`Missing scopes: ${serializedData}`);
|
|
122
136
|
break;
|
|
123
137
|
default:
|
|
124
|
-
messages.push(`${name}: ${
|
|
138
|
+
messages.push(`${name}: ${serializedData}`);
|
|
125
139
|
}
|
|
126
140
|
}, []);
|
|
127
141
|
return messages;
|
|
@@ -1489,94 +1503,102 @@ var QueryAssistanceClient = class {
|
|
|
1489
1503
|
const headerParameters = {
|
|
1490
1504
|
...config.authorization !== void 0 && { Authorization: String(config.authorization) }
|
|
1491
1505
|
};
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
return
|
|
1506
|
+
try {
|
|
1507
|
+
const response = await this.httpClient.send({
|
|
1508
|
+
url: `/platform/storage/query/v1/query:verify`,
|
|
1509
|
+
method: "POST",
|
|
1510
|
+
requestBodyType: "json",
|
|
1511
|
+
body: encodedBody,
|
|
1512
|
+
headers: {
|
|
1513
|
+
"Content-Type": "application/json",
|
|
1514
|
+
Accept: "application/json",
|
|
1515
|
+
...headerParameters
|
|
1516
|
+
},
|
|
1517
|
+
abortSignal: config.abortSignal,
|
|
1518
|
+
statusValidator: (status) => {
|
|
1519
|
+
return [200].includes(status);
|
|
1506
1520
|
}
|
|
1507
|
-
|
|
1521
|
+
});
|
|
1522
|
+
const responseValue = await response.body("json");
|
|
1523
|
+
try {
|
|
1524
|
+
return fromJson19(responseValue);
|
|
1525
|
+
} catch (err) {
|
|
1526
|
+
throw new InvalidResponseError(
|
|
1527
|
+
`QueryAssistanceClient.query:verify:200`,
|
|
1528
|
+
err,
|
|
1529
|
+
responseValue,
|
|
1530
|
+
void 0,
|
|
1531
|
+
void 0
|
|
1532
|
+
);
|
|
1508
1533
|
}
|
|
1509
|
-
})
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1534
|
+
} catch (e) {
|
|
1535
|
+
if (isInvalidResponseError(e)) {
|
|
1536
|
+
throw e;
|
|
1537
|
+
}
|
|
1538
|
+
if (!isHttpClientResponseError(e)) {
|
|
1539
|
+
throw new ApiClientError("UnexpectedError", "Unexpected error", e);
|
|
1540
|
+
}
|
|
1541
|
+
const response = e.response;
|
|
1542
|
+
switch (response.status) {
|
|
1543
|
+
case 400: {
|
|
1544
|
+
const responseValue = await response.body("json");
|
|
1545
|
+
try {
|
|
1546
|
+
const errorBody = fromJson15(responseValue);
|
|
1547
|
+
throw new ErrorEnvelopeError(
|
|
1548
|
+
"400",
|
|
1549
|
+
response,
|
|
1550
|
+
errorBody,
|
|
1551
|
+
getErrorMessage(errorBody, "The supplied request is wrong."),
|
|
1552
|
+
e
|
|
1553
|
+
);
|
|
1554
|
+
} catch (err) {
|
|
1555
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
1556
|
+
throw err;
|
|
1557
|
+
}
|
|
1558
|
+
throw new InvalidResponseError(
|
|
1559
|
+
`QueryAssistanceClient.query:verify:400`,
|
|
1560
|
+
err,
|
|
1561
|
+
responseValue,
|
|
1562
|
+
"ErrorEnvelope",
|
|
1563
|
+
void 0
|
|
1564
|
+
);
|
|
1524
1565
|
}
|
|
1525
|
-
throw new InvalidResponseError(
|
|
1526
|
-
`QueryAssistanceClient.query:verify:400`,
|
|
1527
|
-
err,
|
|
1528
|
-
responseValue,
|
|
1529
|
-
"ErrorEnvelope",
|
|
1530
|
-
void 0
|
|
1531
|
-
);
|
|
1532
1566
|
}
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1567
|
+
case 500: {
|
|
1568
|
+
const responseValue = await response.body("json");
|
|
1569
|
+
try {
|
|
1570
|
+
const errorBody = fromJson15(responseValue);
|
|
1571
|
+
throw new ErrorEnvelopeError(
|
|
1572
|
+
"500",
|
|
1573
|
+
response,
|
|
1574
|
+
errorBody,
|
|
1575
|
+
getErrorMessage(errorBody, "An internal server error has occurred."),
|
|
1576
|
+
e
|
|
1577
|
+
);
|
|
1578
|
+
} catch (err) {
|
|
1579
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
1580
|
+
throw err;
|
|
1581
|
+
}
|
|
1582
|
+
throw new InvalidResponseError(
|
|
1583
|
+
`QueryAssistanceClient.query:verify:500`,
|
|
1584
|
+
err,
|
|
1585
|
+
responseValue,
|
|
1586
|
+
"ErrorEnvelope",
|
|
1587
|
+
void 0
|
|
1588
|
+
);
|
|
1547
1589
|
}
|
|
1548
|
-
throw new InvalidResponseError(
|
|
1549
|
-
`QueryAssistanceClient.query:verify:500`,
|
|
1550
|
-
err,
|
|
1551
|
-
responseValue,
|
|
1552
|
-
"ErrorEnvelope",
|
|
1553
|
-
void 0
|
|
1554
|
-
);
|
|
1555
1590
|
}
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
} catch (err) {
|
|
1562
|
-
throw new InvalidResponseError(
|
|
1563
|
-
`QueryAssistanceClient.query:verify:${response.status}`,
|
|
1564
|
-
err,
|
|
1591
|
+
default: {
|
|
1592
|
+
const responseValue = await response.body("text").catch(() => "");
|
|
1593
|
+
throw new ClientRequestError(
|
|
1594
|
+
`${response.status}`,
|
|
1595
|
+
response,
|
|
1565
1596
|
responseValue,
|
|
1566
|
-
|
|
1567
|
-
|
|
1597
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`),
|
|
1598
|
+
e
|
|
1568
1599
|
);
|
|
1569
1600
|
}
|
|
1570
1601
|
}
|
|
1571
|
-
default: {
|
|
1572
|
-
const responseValue = await response.body("text").catch(() => "");
|
|
1573
|
-
throw new ClientRequestError(
|
|
1574
|
-
`${response.status}`,
|
|
1575
|
-
response,
|
|
1576
|
-
responseValue,
|
|
1577
|
-
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
1578
|
-
);
|
|
1579
|
-
}
|
|
1580
1602
|
}
|
|
1581
1603
|
}
|
|
1582
1604
|
async queryParse(config) {
|
|
@@ -1587,97 +1609,105 @@ var QueryAssistanceClient = class {
|
|
|
1587
1609
|
const headerParameters = {
|
|
1588
1610
|
...config.authorization !== void 0 && { Authorization: String(config.authorization) }
|
|
1589
1611
|
};
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
return
|
|
1612
|
+
try {
|
|
1613
|
+
const response = await this.httpClient.send({
|
|
1614
|
+
url: `/platform/storage/query/v1/query:parse`,
|
|
1615
|
+
method: "POST",
|
|
1616
|
+
requestBodyType: "json",
|
|
1617
|
+
body: encodedBody,
|
|
1618
|
+
headers: {
|
|
1619
|
+
"Content-Type": "application/json",
|
|
1620
|
+
Accept: "application/json",
|
|
1621
|
+
...headerParameters
|
|
1622
|
+
},
|
|
1623
|
+
abortSignal: config.abortSignal,
|
|
1624
|
+
statusValidator: (status) => {
|
|
1625
|
+
return [200].includes(status);
|
|
1604
1626
|
}
|
|
1605
|
-
|
|
1627
|
+
});
|
|
1628
|
+
const responseValue = await response.body("json");
|
|
1629
|
+
try {
|
|
1630
|
+
return fromJson6(responseValue);
|
|
1631
|
+
} catch (err) {
|
|
1632
|
+
throw new InvalidResponseError(
|
|
1633
|
+
`QueryAssistanceClient.query:parse:200`,
|
|
1634
|
+
err,
|
|
1635
|
+
responseValue,
|
|
1636
|
+
void 0,
|
|
1637
|
+
void 0
|
|
1638
|
+
);
|
|
1606
1639
|
}
|
|
1607
|
-
})
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1640
|
+
} catch (e) {
|
|
1641
|
+
if (isInvalidResponseError(e)) {
|
|
1642
|
+
throw e;
|
|
1643
|
+
}
|
|
1644
|
+
if (!isHttpClientResponseError(e)) {
|
|
1645
|
+
throw new ApiClientError("UnexpectedError", "Unexpected error", e);
|
|
1646
|
+
}
|
|
1647
|
+
const response = e.response;
|
|
1648
|
+
switch (response.status) {
|
|
1649
|
+
case 400: {
|
|
1650
|
+
const responseValue = await response.body("json");
|
|
1651
|
+
try {
|
|
1652
|
+
const errorBody = fromJson15(responseValue);
|
|
1653
|
+
throw new ErrorEnvelopeError(
|
|
1654
|
+
"400",
|
|
1655
|
+
response,
|
|
1618
1656
|
errorBody,
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1657
|
+
getErrorMessage(
|
|
1658
|
+
errorBody,
|
|
1659
|
+
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1660
|
+
),
|
|
1661
|
+
e
|
|
1662
|
+
);
|
|
1663
|
+
} catch (err) {
|
|
1664
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
1665
|
+
throw err;
|
|
1666
|
+
}
|
|
1667
|
+
throw new InvalidResponseError(
|
|
1668
|
+
`QueryAssistanceClient.query:parse:400`,
|
|
1669
|
+
err,
|
|
1670
|
+
responseValue,
|
|
1671
|
+
"ErrorEnvelope",
|
|
1672
|
+
void 0
|
|
1673
|
+
);
|
|
1625
1674
|
}
|
|
1626
|
-
throw new InvalidResponseError(
|
|
1627
|
-
`QueryAssistanceClient.query:parse:400`,
|
|
1628
|
-
err,
|
|
1629
|
-
responseValue,
|
|
1630
|
-
"ErrorEnvelope",
|
|
1631
|
-
void 0
|
|
1632
|
-
);
|
|
1633
1675
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1676
|
+
case 500: {
|
|
1677
|
+
const responseValue = await response.body("json");
|
|
1678
|
+
try {
|
|
1679
|
+
const errorBody = fromJson15(responseValue);
|
|
1680
|
+
throw new ErrorEnvelopeError(
|
|
1681
|
+
"500",
|
|
1682
|
+
response,
|
|
1683
|
+
errorBody,
|
|
1684
|
+
getErrorMessage(errorBody, "An internal server error has occurred."),
|
|
1685
|
+
e
|
|
1686
|
+
);
|
|
1687
|
+
} catch (err) {
|
|
1688
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
1689
|
+
throw err;
|
|
1690
|
+
}
|
|
1691
|
+
throw new InvalidResponseError(
|
|
1692
|
+
`QueryAssistanceClient.query:parse:500`,
|
|
1693
|
+
err,
|
|
1694
|
+
responseValue,
|
|
1695
|
+
"ErrorEnvelope",
|
|
1696
|
+
void 0
|
|
1697
|
+
);
|
|
1648
1698
|
}
|
|
1649
|
-
throw new InvalidResponseError(
|
|
1650
|
-
`QueryAssistanceClient.query:parse:500`,
|
|
1651
|
-
err,
|
|
1652
|
-
responseValue,
|
|
1653
|
-
"ErrorEnvelope",
|
|
1654
|
-
void 0
|
|
1655
|
-
);
|
|
1656
1699
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
} catch (err) {
|
|
1663
|
-
throw new InvalidResponseError(
|
|
1664
|
-
`QueryAssistanceClient.query:parse:${response.status}`,
|
|
1665
|
-
err,
|
|
1700
|
+
default: {
|
|
1701
|
+
const responseValue = await response.body("text").catch(() => "");
|
|
1702
|
+
throw new ClientRequestError(
|
|
1703
|
+
`${response.status}`,
|
|
1704
|
+
response,
|
|
1666
1705
|
responseValue,
|
|
1667
|
-
|
|
1668
|
-
|
|
1706
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`),
|
|
1707
|
+
e
|
|
1669
1708
|
);
|
|
1670
1709
|
}
|
|
1671
1710
|
}
|
|
1672
|
-
default: {
|
|
1673
|
-
const responseValue = await response.body("text").catch(() => "");
|
|
1674
|
-
throw new ClientRequestError(
|
|
1675
|
-
`${response.status}`,
|
|
1676
|
-
response,
|
|
1677
|
-
responseValue,
|
|
1678
|
-
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
1679
|
-
);
|
|
1680
|
-
}
|
|
1681
1711
|
}
|
|
1682
1712
|
}
|
|
1683
1713
|
async queryAutocomplete(config) {
|
|
@@ -1688,104 +1718,115 @@ var QueryAssistanceClient = class {
|
|
|
1688
1718
|
const headerParameters = {
|
|
1689
1719
|
...config.authorization !== void 0 && { Authorization: String(config.authorization) }
|
|
1690
1720
|
};
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
return
|
|
1721
|
+
try {
|
|
1722
|
+
const response = await this.httpClient.send({
|
|
1723
|
+
url: `/platform/storage/query/v1/query:autocomplete`,
|
|
1724
|
+
method: "POST",
|
|
1725
|
+
requestBodyType: "json",
|
|
1726
|
+
body: encodedBody,
|
|
1727
|
+
headers: {
|
|
1728
|
+
"Content-Type": "application/json",
|
|
1729
|
+
Accept: "application/json",
|
|
1730
|
+
...headerParameters
|
|
1731
|
+
},
|
|
1732
|
+
abortSignal: config.abortSignal,
|
|
1733
|
+
statusValidator: (status) => {
|
|
1734
|
+
return [200].includes(status);
|
|
1705
1735
|
}
|
|
1706
|
-
|
|
1736
|
+
});
|
|
1737
|
+
const responseValue = await response.body("json");
|
|
1738
|
+
try {
|
|
1739
|
+
return fromJson5(responseValue);
|
|
1740
|
+
} catch (err) {
|
|
1741
|
+
throw new InvalidResponseError(
|
|
1742
|
+
`QueryAssistanceClient.query:autocomplete:200`,
|
|
1743
|
+
err,
|
|
1744
|
+
responseValue,
|
|
1745
|
+
void 0,
|
|
1746
|
+
void 0
|
|
1747
|
+
);
|
|
1707
1748
|
}
|
|
1708
|
-
})
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1749
|
+
} catch (e) {
|
|
1750
|
+
if (isInvalidResponseError(e)) {
|
|
1751
|
+
throw e;
|
|
1752
|
+
}
|
|
1753
|
+
if (!isHttpClientResponseError(e)) {
|
|
1754
|
+
throw new ApiClientError("UnexpectedError", "Unexpected error", e);
|
|
1755
|
+
}
|
|
1756
|
+
const response = e.response;
|
|
1757
|
+
switch (response.status) {
|
|
1758
|
+
case 400: {
|
|
1759
|
+
const responseValue = await response.body("json");
|
|
1760
|
+
try {
|
|
1761
|
+
const errorBody = fromJson15(responseValue);
|
|
1762
|
+
throw new ErrorEnvelopeError(
|
|
1763
|
+
"400",
|
|
1764
|
+
response,
|
|
1719
1765
|
errorBody,
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1766
|
+
getErrorMessage(
|
|
1767
|
+
errorBody,
|
|
1768
|
+
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
1769
|
+
),
|
|
1770
|
+
e
|
|
1771
|
+
);
|
|
1772
|
+
} catch (err) {
|
|
1773
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
1774
|
+
throw err;
|
|
1775
|
+
}
|
|
1776
|
+
throw new InvalidResponseError(
|
|
1777
|
+
`QueryAssistanceClient.query:autocomplete:400`,
|
|
1778
|
+
err,
|
|
1779
|
+
responseValue,
|
|
1780
|
+
"ErrorEnvelope",
|
|
1781
|
+
void 0
|
|
1782
|
+
);
|
|
1726
1783
|
}
|
|
1727
|
-
throw new InvalidResponseError(
|
|
1728
|
-
`QueryAssistanceClient.query:autocomplete:400`,
|
|
1729
|
-
err,
|
|
1730
|
-
responseValue,
|
|
1731
|
-
"ErrorEnvelope",
|
|
1732
|
-
void 0
|
|
1733
|
-
);
|
|
1734
1784
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1785
|
+
case 500: {
|
|
1786
|
+
const responseValue = await response.body("json");
|
|
1787
|
+
try {
|
|
1788
|
+
const errorBody = fromJson15(responseValue);
|
|
1789
|
+
throw new ErrorEnvelopeError(
|
|
1790
|
+
"500",
|
|
1791
|
+
response,
|
|
1792
|
+
errorBody,
|
|
1793
|
+
getErrorMessage(errorBody, "An internal server error has occurred."),
|
|
1794
|
+
e
|
|
1795
|
+
);
|
|
1796
|
+
} catch (err) {
|
|
1797
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
1798
|
+
throw err;
|
|
1799
|
+
}
|
|
1800
|
+
throw new InvalidResponseError(
|
|
1801
|
+
`QueryAssistanceClient.query:autocomplete:500`,
|
|
1802
|
+
err,
|
|
1803
|
+
responseValue,
|
|
1804
|
+
"ErrorEnvelope",
|
|
1805
|
+
void 0
|
|
1806
|
+
);
|
|
1749
1807
|
}
|
|
1750
|
-
throw new InvalidResponseError(
|
|
1751
|
-
`QueryAssistanceClient.query:autocomplete:500`,
|
|
1752
|
-
err,
|
|
1753
|
-
responseValue,
|
|
1754
|
-
"ErrorEnvelope",
|
|
1755
|
-
void 0
|
|
1756
|
-
);
|
|
1757
1808
|
}
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
} catch (err) {
|
|
1764
|
-
throw new InvalidResponseError(
|
|
1765
|
-
`QueryAssistanceClient.query:autocomplete:${response.status}`,
|
|
1766
|
-
err,
|
|
1809
|
+
default: {
|
|
1810
|
+
const responseValue = await response.body("text").catch(() => "");
|
|
1811
|
+
throw new ClientRequestError(
|
|
1812
|
+
`${response.status}`,
|
|
1813
|
+
response,
|
|
1767
1814
|
responseValue,
|
|
1768
|
-
|
|
1769
|
-
|
|
1815
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`),
|
|
1816
|
+
e
|
|
1770
1817
|
);
|
|
1771
1818
|
}
|
|
1772
1819
|
}
|
|
1773
|
-
default: {
|
|
1774
|
-
const responseValue = await response.body("text").catch(() => "");
|
|
1775
|
-
throw new ClientRequestError(
|
|
1776
|
-
`${response.status}`,
|
|
1777
|
-
response,
|
|
1778
|
-
responseValue,
|
|
1779
|
-
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
1780
|
-
);
|
|
1781
|
-
}
|
|
1782
1820
|
}
|
|
1783
1821
|
}
|
|
1784
1822
|
};
|
|
1785
1823
|
var queryAssistanceClient = /* @__PURE__ */ new QueryAssistanceClient(defaultHttpClient);
|
|
1786
1824
|
|
|
1787
1825
|
// packages/client/query/src/lib/apis/query-execution-api.ts
|
|
1788
|
-
import {
|
|
1826
|
+
import {
|
|
1827
|
+
httpClient as defaultHttpClient2,
|
|
1828
|
+
isHttpClientResponseError as isHttpClientResponseError2
|
|
1829
|
+
} from "@dynatrace-sdk/http-client";
|
|
1789
1830
|
|
|
1790
1831
|
// packages/client/query/src/lib/models/execute-request.transformation.ts
|
|
1791
1832
|
var execute_request_transformation_exports = {};
|
|
@@ -3062,102 +3103,104 @@ var QueryExecutionClient = class {
|
|
|
3062
3103
|
"request-timeout-milliseconds": config.requestTimeoutMilliseconds,
|
|
3063
3104
|
enrich: config.enrich
|
|
3064
3105
|
});
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
return
|
|
3106
|
+
try {
|
|
3107
|
+
const response = await this.httpClient.send({
|
|
3108
|
+
url: `/platform/storage/query/v1/query:poll${query}`,
|
|
3109
|
+
method: "GET",
|
|
3110
|
+
headers: {
|
|
3111
|
+
Accept: "application/json"
|
|
3112
|
+
},
|
|
3113
|
+
abortSignal: config.abortSignal,
|
|
3114
|
+
statusValidator: (status) => {
|
|
3115
|
+
return [200].includes(status);
|
|
3075
3116
|
}
|
|
3076
|
-
|
|
3117
|
+
});
|
|
3118
|
+
const responseValue = await response.body("json");
|
|
3119
|
+
try {
|
|
3120
|
+
return fromJson34(responseValue);
|
|
3121
|
+
} catch (err) {
|
|
3122
|
+
throw new InvalidResponseError(`QueryExecutionClient.query:poll:200`, err, responseValue, void 0, void 0);
|
|
3077
3123
|
}
|
|
3078
|
-
})
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3124
|
+
} catch (e) {
|
|
3125
|
+
if (isInvalidResponseError(e)) {
|
|
3126
|
+
throw e;
|
|
3127
|
+
}
|
|
3128
|
+
if (!isHttpClientResponseError2(e)) {
|
|
3129
|
+
throw new ApiClientError("UnexpectedError", "Unexpected error", e);
|
|
3130
|
+
}
|
|
3131
|
+
const response = e.response;
|
|
3132
|
+
switch (response.status) {
|
|
3133
|
+
case 400: {
|
|
3134
|
+
const responseValue = await response.body("json");
|
|
3135
|
+
try {
|
|
3136
|
+
const errorBody = fromJson15(responseValue);
|
|
3137
|
+
throw new ErrorEnvelopeError(
|
|
3138
|
+
"400",
|
|
3139
|
+
response,
|
|
3089
3140
|
errorBody,
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3141
|
+
getErrorMessage(
|
|
3142
|
+
errorBody,
|
|
3143
|
+
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
3144
|
+
),
|
|
3145
|
+
e
|
|
3146
|
+
);
|
|
3147
|
+
} catch (err) {
|
|
3148
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3149
|
+
throw err;
|
|
3150
|
+
}
|
|
3151
|
+
throw new InvalidResponseError(
|
|
3152
|
+
`QueryExecutionClient.query:poll:400`,
|
|
3153
|
+
err,
|
|
3154
|
+
responseValue,
|
|
3155
|
+
"ErrorEnvelope",
|
|
3156
|
+
void 0
|
|
3157
|
+
);
|
|
3096
3158
|
}
|
|
3097
|
-
throw new InvalidResponseError(
|
|
3098
|
-
`QueryExecutionClient.query:poll:400`,
|
|
3099
|
-
err,
|
|
3100
|
-
responseValue,
|
|
3101
|
-
"ErrorEnvelope",
|
|
3102
|
-
void 0
|
|
3103
|
-
);
|
|
3104
3159
|
}
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
`410`,
|
|
3110
|
-
response,
|
|
3111
|
-
responseValue,
|
|
3112
|
-
getErrorMessage(responseValue, `The query for the given request-token is not available anymore.`)
|
|
3113
|
-
);
|
|
3114
|
-
}
|
|
3115
|
-
case 500: {
|
|
3116
|
-
const responseValue = await response.body("json");
|
|
3117
|
-
try {
|
|
3118
|
-
const errorBody = fromJson15(responseValue);
|
|
3119
|
-
throw new ErrorEnvelopeError(
|
|
3120
|
-
"500",
|
|
3160
|
+
case 410: {
|
|
3161
|
+
const responseValue = await response.body("text");
|
|
3162
|
+
throw new ClientRequestError(
|
|
3163
|
+
`410`,
|
|
3121
3164
|
response,
|
|
3122
|
-
errorBody,
|
|
3123
|
-
getErrorMessage(errorBody, "An internal server error has occurred.")
|
|
3124
|
-
);
|
|
3125
|
-
} catch (err) {
|
|
3126
|
-
if (err instanceof ErrorEnvelopeError) {
|
|
3127
|
-
throw err;
|
|
3128
|
-
}
|
|
3129
|
-
throw new InvalidResponseError(
|
|
3130
|
-
`QueryExecutionClient.query:poll:500`,
|
|
3131
|
-
err,
|
|
3132
3165
|
responseValue,
|
|
3133
|
-
|
|
3134
|
-
void 0
|
|
3166
|
+
getErrorMessage(responseValue, `The query for the given request-token is not available anymore.`)
|
|
3135
3167
|
);
|
|
3136
3168
|
}
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3169
|
+
case 500: {
|
|
3170
|
+
const responseValue = await response.body("json");
|
|
3171
|
+
try {
|
|
3172
|
+
const errorBody = fromJson15(responseValue);
|
|
3173
|
+
throw new ErrorEnvelopeError(
|
|
3174
|
+
"500",
|
|
3175
|
+
response,
|
|
3176
|
+
errorBody,
|
|
3177
|
+
getErrorMessage(errorBody, "An internal server error has occurred."),
|
|
3178
|
+
e
|
|
3179
|
+
);
|
|
3180
|
+
} catch (err) {
|
|
3181
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3182
|
+
throw err;
|
|
3183
|
+
}
|
|
3184
|
+
throw new InvalidResponseError(
|
|
3185
|
+
`QueryExecutionClient.query:poll:500`,
|
|
3186
|
+
err,
|
|
3187
|
+
responseValue,
|
|
3188
|
+
"ErrorEnvelope",
|
|
3189
|
+
void 0
|
|
3190
|
+
);
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
default: {
|
|
3194
|
+
const responseValue = await response.body("text").catch(() => "");
|
|
3195
|
+
throw new ClientRequestError(
|
|
3196
|
+
`${response.status}`,
|
|
3197
|
+
response,
|
|
3146
3198
|
responseValue,
|
|
3147
|
-
|
|
3148
|
-
|
|
3199
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`),
|
|
3200
|
+
e
|
|
3149
3201
|
);
|
|
3150
3202
|
}
|
|
3151
3203
|
}
|
|
3152
|
-
default: {
|
|
3153
|
-
const responseValue = await response.body("text").catch(() => "");
|
|
3154
|
-
throw new ClientRequestError(
|
|
3155
|
-
`${response.status}`,
|
|
3156
|
-
response,
|
|
3157
|
-
responseValue,
|
|
3158
|
-
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
3159
|
-
);
|
|
3160
|
-
}
|
|
3161
3204
|
}
|
|
3162
3205
|
}
|
|
3163
3206
|
async queryExecute(config) {
|
|
@@ -3169,133 +3212,241 @@ var QueryExecutionClient = class {
|
|
|
3169
3212
|
const headerParameters = {
|
|
3170
3213
|
...config.authorization !== void 0 && { Authorization: String(config.authorization) }
|
|
3171
3214
|
};
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
return
|
|
3215
|
+
try {
|
|
3216
|
+
const response = await this.httpClient.send({
|
|
3217
|
+
url: `/platform/storage/query/v1/query:execute${query}`,
|
|
3218
|
+
method: "POST",
|
|
3219
|
+
requestBodyType: "json",
|
|
3220
|
+
body: encodedBody,
|
|
3221
|
+
headers: {
|
|
3222
|
+
"Content-Type": "application/json",
|
|
3223
|
+
Accept: "application/json",
|
|
3224
|
+
...headerParameters
|
|
3225
|
+
},
|
|
3226
|
+
abortSignal: config.abortSignal,
|
|
3227
|
+
statusValidator: (status) => {
|
|
3228
|
+
return [200, 202].includes(status);
|
|
3186
3229
|
}
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
3202
|
-
)
|
|
3203
|
-
);
|
|
3204
|
-
} catch (err) {
|
|
3205
|
-
if (err instanceof ErrorEnvelopeError) {
|
|
3206
|
-
throw err;
|
|
3230
|
+
});
|
|
3231
|
+
switch (response.status) {
|
|
3232
|
+
case 200: {
|
|
3233
|
+
const responseValue = await response.body("json");
|
|
3234
|
+
try {
|
|
3235
|
+
return fromJson35(responseValue);
|
|
3236
|
+
} catch (err) {
|
|
3237
|
+
throw new InvalidResponseError(
|
|
3238
|
+
`QueryExecutionClient.query:execute:${response.status}`,
|
|
3239
|
+
err,
|
|
3240
|
+
responseValue,
|
|
3241
|
+
void 0,
|
|
3242
|
+
void 0
|
|
3243
|
+
);
|
|
3207
3244
|
}
|
|
3208
|
-
throw new InvalidResponseError(
|
|
3209
|
-
`QueryExecutionClient.query:execute:400`,
|
|
3210
|
-
err,
|
|
3211
|
-
responseValue,
|
|
3212
|
-
"ErrorEnvelope",
|
|
3213
|
-
void 0
|
|
3214
|
-
);
|
|
3215
3245
|
}
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
if (err instanceof ErrorEnvelopeError) {
|
|
3229
|
-
throw err;
|
|
3246
|
+
case 202: {
|
|
3247
|
+
const responseValue = await response.body("json");
|
|
3248
|
+
try {
|
|
3249
|
+
return fromJson35(responseValue);
|
|
3250
|
+
} catch (err) {
|
|
3251
|
+
throw new InvalidResponseError(
|
|
3252
|
+
`QueryExecutionClient.query:execute:${response.status}`,
|
|
3253
|
+
err,
|
|
3254
|
+
responseValue,
|
|
3255
|
+
void 0,
|
|
3256
|
+
void 0
|
|
3257
|
+
);
|
|
3230
3258
|
}
|
|
3231
|
-
throw new InvalidResponseError(
|
|
3232
|
-
`QueryExecutionClient.query:execute:500`,
|
|
3233
|
-
err,
|
|
3234
|
-
responseValue,
|
|
3235
|
-
"ErrorEnvelope",
|
|
3236
|
-
void 0
|
|
3237
|
-
);
|
|
3238
3259
|
}
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
const errorBody = fromJson15(responseValue);
|
|
3244
|
-
throw new ErrorEnvelopeError(
|
|
3245
|
-
"503",
|
|
3260
|
+
default: {
|
|
3261
|
+
const responseValue = await response.body("text").catch(() => "");
|
|
3262
|
+
throw new ClientRequestError(
|
|
3263
|
+
`${response.status}`,
|
|
3246
3264
|
response,
|
|
3247
|
-
errorBody,
|
|
3248
|
-
getErrorMessage(errorBody, "Service is unavailable.")
|
|
3249
|
-
);
|
|
3250
|
-
} catch (err) {
|
|
3251
|
-
if (err instanceof ErrorEnvelopeError) {
|
|
3252
|
-
throw err;
|
|
3253
|
-
}
|
|
3254
|
-
throw new InvalidResponseError(
|
|
3255
|
-
`QueryExecutionClient.query:execute:503`,
|
|
3256
|
-
err,
|
|
3257
3265
|
responseValue,
|
|
3258
|
-
"
|
|
3259
|
-
void 0
|
|
3266
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
3260
3267
|
);
|
|
3261
3268
|
}
|
|
3262
3269
|
}
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
return fromJson35(responseValue);
|
|
3267
|
-
} catch (err) {
|
|
3268
|
-
throw new InvalidResponseError(
|
|
3269
|
-
`QueryExecutionClient.query:execute:${response.status}`,
|
|
3270
|
-
err,
|
|
3271
|
-
responseValue,
|
|
3272
|
-
void 0,
|
|
3273
|
-
void 0
|
|
3274
|
-
);
|
|
3275
|
-
}
|
|
3270
|
+
} catch (e) {
|
|
3271
|
+
if (isClientRequestError(e) || isInvalidResponseError(e)) {
|
|
3272
|
+
throw e;
|
|
3276
3273
|
}
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
try {
|
|
3280
|
-
return fromJson35(responseValue);
|
|
3281
|
-
} catch (err) {
|
|
3282
|
-
throw new InvalidResponseError(
|
|
3283
|
-
`QueryExecutionClient.query:execute:${response.status}`,
|
|
3284
|
-
err,
|
|
3285
|
-
responseValue,
|
|
3286
|
-
void 0,
|
|
3287
|
-
void 0
|
|
3288
|
-
);
|
|
3289
|
-
}
|
|
3274
|
+
if (!isHttpClientResponseError2(e)) {
|
|
3275
|
+
throw new ApiClientError("UnexpectedError", "Unexpected error", e);
|
|
3290
3276
|
}
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3277
|
+
const response = e.response;
|
|
3278
|
+
switch (response.status) {
|
|
3279
|
+
case 400: {
|
|
3280
|
+
const responseValue = await response.body("json");
|
|
3281
|
+
try {
|
|
3282
|
+
const errorBody = fromJson15(responseValue);
|
|
3283
|
+
throw new ErrorEnvelopeError(
|
|
3284
|
+
"400",
|
|
3285
|
+
response,
|
|
3286
|
+
errorBody,
|
|
3287
|
+
getErrorMessage(
|
|
3288
|
+
errorBody,
|
|
3289
|
+
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
3290
|
+
),
|
|
3291
|
+
e
|
|
3292
|
+
);
|
|
3293
|
+
} catch (err) {
|
|
3294
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3295
|
+
throw err;
|
|
3296
|
+
}
|
|
3297
|
+
throw new InvalidResponseError(
|
|
3298
|
+
`QueryExecutionClient.query:execute:400`,
|
|
3299
|
+
err,
|
|
3300
|
+
responseValue,
|
|
3301
|
+
"ErrorEnvelope",
|
|
3302
|
+
void 0
|
|
3303
|
+
);
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
case 403: {
|
|
3307
|
+
const responseValue = await response.body("json");
|
|
3308
|
+
try {
|
|
3309
|
+
const errorBody = fromJson15(responseValue);
|
|
3310
|
+
throw new ErrorEnvelopeError(
|
|
3311
|
+
"403",
|
|
3312
|
+
response,
|
|
3313
|
+
errorBody,
|
|
3314
|
+
getErrorMessage(errorBody, "Insufficient permissions."),
|
|
3315
|
+
e
|
|
3316
|
+
);
|
|
3317
|
+
} catch (err) {
|
|
3318
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3319
|
+
throw err;
|
|
3320
|
+
}
|
|
3321
|
+
throw new InvalidResponseError(
|
|
3322
|
+
`QueryExecutionClient.query:execute:403`,
|
|
3323
|
+
err,
|
|
3324
|
+
responseValue,
|
|
3325
|
+
"ErrorEnvelope",
|
|
3326
|
+
void 0
|
|
3327
|
+
);
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
case 429: {
|
|
3331
|
+
const responseValue = await response.body("json");
|
|
3332
|
+
try {
|
|
3333
|
+
const errorBody = fromJson15(responseValue);
|
|
3334
|
+
throw new ErrorEnvelopeError(
|
|
3335
|
+
"429",
|
|
3336
|
+
response,
|
|
3337
|
+
errorBody,
|
|
3338
|
+
getErrorMessage(errorBody, "Too many requests."),
|
|
3339
|
+
e
|
|
3340
|
+
);
|
|
3341
|
+
} catch (err) {
|
|
3342
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3343
|
+
throw err;
|
|
3344
|
+
}
|
|
3345
|
+
throw new InvalidResponseError(
|
|
3346
|
+
`QueryExecutionClient.query:execute:429`,
|
|
3347
|
+
err,
|
|
3348
|
+
responseValue,
|
|
3349
|
+
"ErrorEnvelope",
|
|
3350
|
+
void 0
|
|
3351
|
+
);
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
case 500: {
|
|
3355
|
+
const responseValue = await response.body("json");
|
|
3356
|
+
try {
|
|
3357
|
+
const errorBody = fromJson15(responseValue);
|
|
3358
|
+
throw new ErrorEnvelopeError(
|
|
3359
|
+
"500",
|
|
3360
|
+
response,
|
|
3361
|
+
errorBody,
|
|
3362
|
+
getErrorMessage(errorBody, "An internal server error has occurred."),
|
|
3363
|
+
e
|
|
3364
|
+
);
|
|
3365
|
+
} catch (err) {
|
|
3366
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3367
|
+
throw err;
|
|
3368
|
+
}
|
|
3369
|
+
throw new InvalidResponseError(
|
|
3370
|
+
`QueryExecutionClient.query:execute:500`,
|
|
3371
|
+
err,
|
|
3372
|
+
responseValue,
|
|
3373
|
+
"ErrorEnvelope",
|
|
3374
|
+
void 0
|
|
3375
|
+
);
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
case 503: {
|
|
3379
|
+
const responseValue = await response.body("json");
|
|
3380
|
+
try {
|
|
3381
|
+
const errorBody = fromJson15(responseValue);
|
|
3382
|
+
throw new ErrorEnvelopeError(
|
|
3383
|
+
"503",
|
|
3384
|
+
response,
|
|
3385
|
+
errorBody,
|
|
3386
|
+
getErrorMessage(errorBody, "Service is unavailable."),
|
|
3387
|
+
e
|
|
3388
|
+
);
|
|
3389
|
+
} catch (err) {
|
|
3390
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3391
|
+
throw err;
|
|
3392
|
+
}
|
|
3393
|
+
throw new InvalidResponseError(
|
|
3394
|
+
`QueryExecutionClient.query:execute:503`,
|
|
3395
|
+
err,
|
|
3396
|
+
responseValue,
|
|
3397
|
+
"ErrorEnvelope",
|
|
3398
|
+
void 0
|
|
3399
|
+
);
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
default: {
|
|
3403
|
+
if (response.status >= 400 && response.status <= 499) {
|
|
3404
|
+
const responseValue = await response.body("json");
|
|
3405
|
+
try {
|
|
3406
|
+
const errorBody = fromJson15(responseValue);
|
|
3407
|
+
throw new ErrorEnvelopeError("4XX", response, errorBody, getErrorMessage(errorBody, "Client error."), e);
|
|
3408
|
+
} catch (err) {
|
|
3409
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3410
|
+
throw err;
|
|
3411
|
+
}
|
|
3412
|
+
throw new InvalidResponseError(
|
|
3413
|
+
`QueryExecutionClient.query:execute:4XX`,
|
|
3414
|
+
err,
|
|
3415
|
+
responseValue,
|
|
3416
|
+
"ErrorEnvelope",
|
|
3417
|
+
void 0
|
|
3418
|
+
);
|
|
3419
|
+
}
|
|
3420
|
+
} else if (response.status >= 500 && response.status <= 599) {
|
|
3421
|
+
const responseValue = await response.body("json");
|
|
3422
|
+
try {
|
|
3423
|
+
const errorBody = fromJson15(responseValue);
|
|
3424
|
+
throw new ErrorEnvelopeError("5XX", response, errorBody, getErrorMessage(errorBody, "Server error."), e);
|
|
3425
|
+
} catch (err) {
|
|
3426
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3427
|
+
throw err;
|
|
3428
|
+
}
|
|
3429
|
+
throw new InvalidResponseError(
|
|
3430
|
+
`QueryExecutionClient.query:execute:5XX`,
|
|
3431
|
+
err,
|
|
3432
|
+
responseValue,
|
|
3433
|
+
"ErrorEnvelope",
|
|
3434
|
+
void 0
|
|
3435
|
+
);
|
|
3436
|
+
}
|
|
3437
|
+
} else {
|
|
3438
|
+
const responseValue = await response.body("text").catch(() => "");
|
|
3439
|
+
throw new ClientRequestError(
|
|
3440
|
+
`${response.status}`,
|
|
3441
|
+
response,
|
|
3442
|
+
responseValue,
|
|
3443
|
+
getErrorMessage(
|
|
3444
|
+
responseValue,
|
|
3445
|
+
`Unexpected api response: code=${response.status} body="${responseValue}"`
|
|
3446
|
+
)
|
|
3447
|
+
);
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3299
3450
|
}
|
|
3300
3451
|
}
|
|
3301
3452
|
}
|
|
@@ -3303,106 +3454,127 @@ var QueryExecutionClient = class {
|
|
|
3303
3454
|
if (!config) {
|
|
3304
3455
|
throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
|
|
3305
3456
|
}
|
|
3306
|
-
const query = toQueryString({ "request-token": config.requestToken });
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
return
|
|
3457
|
+
const query = toQueryString({ "request-token": config.requestToken, enrich: config.enrich });
|
|
3458
|
+
try {
|
|
3459
|
+
const response = await this.httpClient.send({
|
|
3460
|
+
url: `/platform/storage/query/v1/query:cancel${query}`,
|
|
3461
|
+
method: "POST",
|
|
3462
|
+
headers: {
|
|
3463
|
+
Accept: "application/json"
|
|
3464
|
+
},
|
|
3465
|
+
abortSignal: config.abortSignal,
|
|
3466
|
+
statusValidator: (status) => {
|
|
3467
|
+
return [200, 202].includes(status);
|
|
3317
3468
|
}
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
3333
|
-
)
|
|
3334
|
-
);
|
|
3335
|
-
} catch (err) {
|
|
3336
|
-
if (err instanceof ErrorEnvelopeError) {
|
|
3337
|
-
throw err;
|
|
3469
|
+
});
|
|
3470
|
+
switch (response.status) {
|
|
3471
|
+
case 200: {
|
|
3472
|
+
const responseValue = await response.body("json");
|
|
3473
|
+
try {
|
|
3474
|
+
return fromJson34(responseValue);
|
|
3475
|
+
} catch (err) {
|
|
3476
|
+
throw new InvalidResponseError(
|
|
3477
|
+
`QueryExecutionClient.query:cancel:${response.status}`,
|
|
3478
|
+
err,
|
|
3479
|
+
responseValue,
|
|
3480
|
+
void 0,
|
|
3481
|
+
void 0
|
|
3482
|
+
);
|
|
3338
3483
|
}
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3484
|
+
}
|
|
3485
|
+
case 202: {
|
|
3486
|
+
return;
|
|
3487
|
+
}
|
|
3488
|
+
default: {
|
|
3489
|
+
const responseValue = await response.body("text").catch(() => "");
|
|
3490
|
+
throw new ClientRequestError(
|
|
3491
|
+
`${response.status}`,
|
|
3492
|
+
response,
|
|
3342
3493
|
responseValue,
|
|
3343
|
-
"
|
|
3344
|
-
void 0
|
|
3494
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
3345
3495
|
);
|
|
3346
3496
|
}
|
|
3347
3497
|
}
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
throw
|
|
3351
|
-
`410`,
|
|
3352
|
-
response,
|
|
3353
|
-
responseValue,
|
|
3354
|
-
getErrorMessage(responseValue, `The query for the given request-token is not available anymore.`)
|
|
3355
|
-
);
|
|
3498
|
+
} catch (e) {
|
|
3499
|
+
if (isClientRequestError(e) || isInvalidResponseError(e)) {
|
|
3500
|
+
throw e;
|
|
3356
3501
|
}
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3502
|
+
if (!isHttpClientResponseError2(e)) {
|
|
3503
|
+
throw new ApiClientError("UnexpectedError", "Unexpected error", e);
|
|
3504
|
+
}
|
|
3505
|
+
const response = e.response;
|
|
3506
|
+
switch (response.status) {
|
|
3507
|
+
case 400: {
|
|
3508
|
+
const responseValue = await response.body("json");
|
|
3509
|
+
try {
|
|
3510
|
+
const errorBody = fromJson15(responseValue);
|
|
3511
|
+
throw new ErrorEnvelopeError(
|
|
3512
|
+
"400",
|
|
3513
|
+
response,
|
|
3514
|
+
errorBody,
|
|
3515
|
+
getErrorMessage(
|
|
3516
|
+
errorBody,
|
|
3517
|
+
"The supplied request is wrong. Either the query itself or other parameters are wrong."
|
|
3518
|
+
),
|
|
3519
|
+
e
|
|
3520
|
+
);
|
|
3521
|
+
} catch (err) {
|
|
3522
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3523
|
+
throw err;
|
|
3524
|
+
}
|
|
3525
|
+
throw new InvalidResponseError(
|
|
3526
|
+
`QueryExecutionClient.query:cancel:400`,
|
|
3527
|
+
err,
|
|
3528
|
+
responseValue,
|
|
3529
|
+
"ErrorEnvelope",
|
|
3530
|
+
void 0
|
|
3531
|
+
);
|
|
3370
3532
|
}
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3533
|
+
}
|
|
3534
|
+
case 410: {
|
|
3535
|
+
const responseValue = await response.body("text");
|
|
3536
|
+
throw new ClientRequestError(
|
|
3537
|
+
`410`,
|
|
3538
|
+
response,
|
|
3374
3539
|
responseValue,
|
|
3375
|
-
|
|
3376
|
-
void 0
|
|
3540
|
+
getErrorMessage(responseValue, `The query for the given request-token is not available anymore.`)
|
|
3377
3541
|
);
|
|
3378
3542
|
}
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3543
|
+
case 500: {
|
|
3544
|
+
const responseValue = await response.body("json");
|
|
3545
|
+
try {
|
|
3546
|
+
const errorBody = fromJson15(responseValue);
|
|
3547
|
+
throw new ErrorEnvelopeError(
|
|
3548
|
+
"500",
|
|
3549
|
+
response,
|
|
3550
|
+
errorBody,
|
|
3551
|
+
getErrorMessage(errorBody, "An internal server error has occurred."),
|
|
3552
|
+
e
|
|
3553
|
+
);
|
|
3554
|
+
} catch (err) {
|
|
3555
|
+
if (err instanceof ErrorEnvelopeError) {
|
|
3556
|
+
throw err;
|
|
3557
|
+
}
|
|
3558
|
+
throw new InvalidResponseError(
|
|
3559
|
+
`QueryExecutionClient.query:cancel:500`,
|
|
3560
|
+
err,
|
|
3561
|
+
responseValue,
|
|
3562
|
+
"ErrorEnvelope",
|
|
3563
|
+
void 0
|
|
3564
|
+
);
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
default: {
|
|
3568
|
+
const responseValue = await response.body("text").catch(() => "");
|
|
3569
|
+
throw new ClientRequestError(
|
|
3570
|
+
`${response.status}`,
|
|
3571
|
+
response,
|
|
3388
3572
|
responseValue,
|
|
3389
|
-
|
|
3390
|
-
|
|
3573
|
+
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`),
|
|
3574
|
+
e
|
|
3391
3575
|
);
|
|
3392
3576
|
}
|
|
3393
3577
|
}
|
|
3394
|
-
case 202: {
|
|
3395
|
-
return;
|
|
3396
|
-
}
|
|
3397
|
-
default: {
|
|
3398
|
-
const responseValue = await response.body("text").catch(() => "");
|
|
3399
|
-
throw new ClientRequestError(
|
|
3400
|
-
`${response.status}`,
|
|
3401
|
-
response,
|
|
3402
|
-
responseValue,
|
|
3403
|
-
getErrorMessage(responseValue, `Unexpected api response: code=${response.status} body="${responseValue}"`)
|
|
3404
|
-
);
|
|
3405
|
-
}
|
|
3406
3578
|
}
|
|
3407
3579
|
}
|
|
3408
3580
|
};
|
|
@@ -3430,6 +3602,7 @@ var FieldTypeType = /* @__PURE__ */ ((FieldTypeType2) => {
|
|
|
3430
3602
|
FieldTypeType2["GeoPoint"] = "geo_point";
|
|
3431
3603
|
FieldTypeType2["Array"] = "array";
|
|
3432
3604
|
FieldTypeType2["Record"] = "record";
|
|
3605
|
+
FieldTypeType2["Uid"] = "uid";
|
|
3433
3606
|
FieldTypeType2["Undefined"] = "undefined";
|
|
3434
3607
|
return FieldTypeType2;
|
|
3435
3608
|
})(FieldTypeType || {});
|
|
@@ -3484,6 +3657,7 @@ var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
|
3484
3657
|
TokenType2["MetricKey"] = "METRIC_KEY";
|
|
3485
3658
|
TokenType2["Variable"] = "VARIABLE";
|
|
3486
3659
|
TokenType2["EndComment"] = "END_COMMENT";
|
|
3660
|
+
TokenType2["UidValue"] = "UID_VALUE";
|
|
3487
3661
|
return TokenType2;
|
|
3488
3662
|
})(TokenType || {});
|
|
3489
3663
|
export {
|