@dynatrace-sdk/client-query 1.11.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +50 -46
  3. package/cjs/index.js +441 -2
  4. package/docs/DOCS.md +7 -7
  5. package/esm/index.js +441 -2
  6. package/package.json +1 -1
  7. package/types/packages/client/query/src/lib/models/dql-node-node-type.transformation.d.ts +1 -1
  8. package/types/packages/client/query/src/lib/models/field-type-type.transformation.d.ts +1 -1
  9. package/types/packages/client/query/src/lib/models/query-state.transformation.d.ts +1 -1
  10. package/types/packages/client/query/src/lib/models/result-record-value.d.ts +1 -1
  11. package/types/packages/client/query/src/lib/models/result-record-value.transformation.d.ts +1 -1
  12. package/types/packages/client/query/src/lib/models/token-type.transformation.d.ts +1 -1
  13. package/types/packages/client/query/src/lib/utils/url-helpers.d.ts +1 -1
  14. package/types/packages/http-client/src/lib/platform/abort-controller.d.ts +1 -1
  15. package/types/packages/http-client/src/lib/platform/abort-signal.d.ts +1 -1
  16. package/types/packages/http-client/src/lib/platform/decode-form-data.d.ts +48 -0
  17. package/types/packages/http-client/src/lib/platform/http-client.d.ts +8 -0
  18. package/types/packages/http-client/src/lib/types/data-types.d.ts +1 -1
  19. package/types/packages/http-client/src/lib/types/form-data-request-body.d.ts +2 -2
  20. package/types/packages/http-client/src/lib/types/form-data-response-body.d.ts +2 -2
  21. package/types/packages/http-client/src/lib/types/request-body-types.d.ts +1 -1
  22. package/types/packages/http-client/src/lib/types/response-body-types.d.ts +1 -1
  23. package/types/packages/platform/error-handlers/src/lib/types/global-dt-runtime-with-error-handlers.d.ts +1 -1
  24. package/types/packages/platform/error-handlers/src/lib/types/global-error-serializer.d.ts +1 -1
  25. package/types/packages/platform/error-handlers/src/lib/types/serialized-error.d.ts +1 -1
package/esm/index.js CHANGED
@@ -1577,10 +1577,37 @@ function toJson20($model) {
1577
1577
  // packages/client/query/src/lib/apis/query-assistance-api.ts
1578
1578
  var QueryAssistanceClient = class {
1579
1579
  httpClient;
1580
+ /**
1581
+ * @param {HttpClient} httpClientImplementation - You can provide custom http client as a parameter to constructor of a QueryAssistanceClient. Custom http client should implement {HttpClient} interface.
1582
+ * @example
1583
+ * const queryAssistanceClientNodeJs = new QueryAssistanceClient(yourCustomImplementation);
1584
+ */
1580
1585
  constructor(httpClientImplementation) {
1581
1586
  this.httpClient = httpClientImplementation;
1582
1587
  registerGlobalErrorSerializer(apiClientErrorSerializer);
1583
1588
  }
1589
+ /**
1590
+ * Verifies a query without executing it.
1591
+ *
1592
+ * For information about the required permissions see the [Bucket and table permissions in Grail documentation](https://docs.dynatrace.com/docs/shortlink/assign-bucket-table-permissions).
1593
+ *
1594
+ * ## Overview
1595
+ *
1596
+ * Verifies the supplied query string and other query parameters for lack of any errors, but without actually
1597
+ * submitting the query for execution.
1598
+ *
1599
+ * @returns Supplied query and parameters were verified.
1600
+ *
1601
+ * @example <caption>Code example</caption>
1602
+ * import { queryAssistanceClient } from "@dynatrace-sdk/client-query";
1603
+ *
1604
+ * const data = await queryAssistanceClient.queryVerify({
1605
+ * body: {
1606
+ * query:
1607
+ * 'fetch events | filter event.type == "davis" AND davis.status != "CLOSED" | fields timestamp, davis.title, davis.underMaintenance, davis.status | sort timestamp | limit 10',
1608
+ * },
1609
+ * });
1610
+ */
1584
1611
  async queryVerify(config) {
1585
1612
  if (!config) {
1586
1613
  throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
@@ -1683,6 +1710,213 @@ var QueryAssistanceClient = class {
1683
1710
  }
1684
1711
  }
1685
1712
  }
1713
+ /**
1714
+ * Get a structured tree of the canonical form of the query.
1715
+ *
1716
+ * For information about the required permissions see the [Bucket and table permissions in Grail documentation](https://docs.dynatrace.com/docs/shortlink/assign-bucket-table-permissions).
1717
+ *
1718
+ * ## Overview
1719
+ *
1720
+ * Returns the parsed query as a tree, containing the structure of the canonical query. Tree-nodes can contain references to
1721
+ * the token position where they originate from. This may help to provide hover effects, show canonical forms, mark
1722
+ * optional items, and more.
1723
+ *
1724
+ * ## Details
1725
+ *
1726
+ * The query tree consists of nodes that contain different additional information (everything optional):
1727
+ *
1728
+ * ### General Fields
1729
+ *
1730
+ * Field | Mandatory | Description
1731
+ * ----------------------- | --- | ----------------------------------------------------------------------------------------
1732
+ * tokenPosition | no | optional. If present, it represents the position within the query string where the node refers to.
1733
+ * isOptional | no | whether this node could be left out and the result would still be the same query (semantically).
1734
+ *
1735
+ * #### tokenPosition
1736
+ *
1737
+ * contains `start` (inclusive) and `end` (inclusive), both contain `index` (0 based; fur substrings), `line`
1738
+ * and `column` (both 1-based; for readability).
1739
+ *
1740
+ * * If `tokenPosition` is present, it always contains start and end with all fields
1741
+ * * If `tokenPosition` is not present, there might still be nested nodes that do contain a position
1742
+ * * If `start == end`, the position refers to a single character
1743
+ * * If `start > end`, we know for sure that something was inserted.
1744
+ *
1745
+ * We can always check whether the canonical representation of a node matches the text in the tokenPosition to see whether
1746
+ * something was inserted, removed, or changed.
1747
+ *
1748
+ * #### isOptional
1749
+ *
1750
+ * only present if it is true.
1751
+ *
1752
+ * Optional nodes can e.g. be optional braces that make a query more readable, but are not necessary. This could be used to
1753
+ * enter *ghost braces* and *implicit functions* in the user's input field; maybe with different formatting
1754
+ * (using the tokenPosition of sibling nodes we can also check whether the user wrote these or not).
1755
+ *
1756
+ * ### Advanced Token Types
1757
+ *
1758
+ * each node is of one of following types and may contain more fields:
1759
+ *
1760
+ * * Terminal Node
1761
+ * * ContainerNode
1762
+ * * Alternative Node
1763
+ *
1764
+ * #### Terminal Node
1765
+ *
1766
+ * can be identified by checking whether `canonicalString` is present
1767
+ *
1768
+ * Field | Mandatory | Description
1769
+ * ------------------------ | --- | ---------------------------------------------------------------------------------------
1770
+ * type | yes | the type of the terminal node - do not confuse with the type of container nodes
1771
+ * canonicalString | yes | the canonical string representation. Concatenating the canonicalString of all nested terminal nodes provides the canonical form of the query.
1772
+ * 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)
1773
+ *
1774
+ * ##### Current types of terminal nodes (list might grow):
1775
+ *
1776
+ * * SPACE
1777
+ * * LINEBREAK
1778
+ * * INDENT
1779
+ * * PIPE
1780
+ * * DOT
1781
+ * * COLON
1782
+ * * COMMA
1783
+ * * BRACE_OPEN
1784
+ * * BRACE_CLOSE
1785
+ * * BRACKET_OPEN
1786
+ * * BRACKET_CLOSE
1787
+ * * PARENTHESIS_OPEN
1788
+ * * PARENTHESIS_CLOSE
1789
+ * * QUOTE
1790
+ * * SLASH
1791
+ * * BOOLEAN_TRUE
1792
+ * * BOOLEAN_FALSE
1793
+ * * NULL
1794
+ * * COMMAND_NAME
1795
+ * * PARAMETER_KEY
1796
+ * * PARAMETER_VALUE_SCOPE
1797
+ * * FUNCTION_NAME
1798
+ * * OPERATOR
1799
+ * * TRAVERSAL_OPERATOR
1800
+ * * TRAVERSAL_RELATION_NAME
1801
+ * * TRAVERSAL_HOP_COUNT
1802
+ * * SIMPLE_IDENTIFIER
1803
+ * * NUMBER
1804
+ * * STRING
1805
+ * * TIME_UNIT
1806
+ * * TIMESTAMP_VALUE
1807
+ * * METRIC_KEY
1808
+ * * VARIABLE
1809
+ *
1810
+ * #### ContainerNode
1811
+ *
1812
+ * can be identified by checking whether `children` is present
1813
+ *
1814
+ * Field | Mandatory | Description
1815
+ * ----------------------- | --- | ----------------------------------------------------------------------------------------
1816
+ * type | yes | the type of the container node - do not confuse with the type of terminal nodes
1817
+ * children | yes | the children for the node. might be of any type
1818
+ *
1819
+ * ##### Current types of container nodes (list might grow):
1820
+ *
1821
+ * * QUERY
1822
+ * * EXECUTION_BLOCK
1823
+ * * COMMAND
1824
+ * * COMMAND_SEPARATOR
1825
+ * * PARAMETER_WITH_KEY
1826
+ * * GROUP
1827
+ * * PARAMETERS - check examples further down
1828
+ * * PARAMETER_NAMING
1829
+ * * PARAMETER_SEPARATOR
1830
+ * * FUNCTION
1831
+ * * FUNCTION_PART - check examples further down
1832
+ * * EXPRESSION
1833
+ * * IDENTIFIER
1834
+ * * SOURCE_ID
1835
+ * * DURATION
1836
+ * * TIMESTAMP
1837
+ * * TIMEFRAME
1838
+ * * TRAVERSAL_PATH
1839
+ * * TRAVERSAL_STEP
1840
+ *
1841
+ * ##### Special node type: PARAMETERS
1842
+ *
1843
+ * can contain children representing the parameters. Every second child is of type PARAMETER_SEPARATOR.
1844
+ *
1845
+ * You may reorder the children based on their tokenPosition to get the user order. However, in this case,
1846
+ * you need to consider `isMandatoryOnUserOrder` to determine whether the grouping braces are mandatory or not.
1847
+ *
1848
+ * ###### Example
1849
+ *
1850
+ * For the query `SORT a, {direction:"descending", b}`, the canonical form is:
1851
+ *
1852
+ * `SORT a, {b, direction:"descending"}`
1853
+ *
1854
+ * This is the order, in which the parameters are returned in the query tree.
1855
+ * Parameters are {a} and {{b} and {direction:"descending"}}. In this case, the braces are optional.
1856
+ *
1857
+ * `SORT a, {b, direction:"descending"}` is equivalent to `SORT a, b, direction:"descending"`
1858
+ *
1859
+ * However, if you reorder the children by tokenPosition, the braces are not optional, because
1860
+ *
1861
+ * `SORT a, direction:"descending", b` is interpreted as `SORT {a, direction:"descending"}, b`
1862
+ *
1863
+ * So, if the children in PARAMETERS are re-ordered by tokenPosition, braces (or in general: TerminalNodes)
1864
+ * are only optional if `isOptional && !isMandatoryOnUserOrder`.
1865
+ *
1866
+ * ##### Special node type: FUNCTION_PART
1867
+ *
1868
+ * A container node of type `FUNCTION` may contain nodes of type `FUNCTION_PART`.
1869
+ *
1870
+ * If those `FUNCTION_PART`s are marked as optional, this means you have to either include *all* or *none* of these
1871
+ * optional function parts.
1872
+ *
1873
+ * *Example*:
1874
+ *
1875
+ * `filter anyMatch(a.b == 1, input:a)`
1876
+ *
1877
+ * The optional function parts are `anyMatch(` and `, input:a)`. If you leave out both, the command will still work:
1878
+ * `filter a.b == 1` and return the same result. Using one of these optional function parts and removing the other will lead
1879
+ * to an invalid query.
1880
+ *
1881
+ * #### Alternative Node
1882
+ *
1883
+ * can be identified by checking whether `alternatives` is present
1884
+ *
1885
+ * Field | Mandatory | Description
1886
+ * ----------------------- | --- | ----------------------------------------------------------------------------------------
1887
+ * alternatives | yes | Type: Map&lt;AlternativeType, DQLNode&gt;
1888
+ *
1889
+ * When displaying the query, pick one option. You may use the other options for hovering, replacing, and more.
1890
+ *
1891
+ * ##### Current values of AlternativeType (list might grow):
1892
+ *
1893
+ * * CANONICAL: This node is the one we will use for our canonical form
1894
+ * * USER: An alternative that is also valid, but not canonical; and this version was picked by the user.
1895
+ * * INFO: only if the canonical version is not present
1896
+ *
1897
+ * *Examples*:
1898
+ *
1899
+ * * `CANONICAL` is not present, `USER` is present: user's nodes are optional, but not canonical (usually optional nodes
1900
+ * are still canonical)
1901
+ * * `CANONICAL` is present, `USER` is not present: same as if the canonical node was optional. If this happens, it is
1902
+ * likely that there is also an `INFO` node
1903
+ * * `CANONICAL` is present, `USER` is present: there are different alternatives
1904
+ * * `INFO` is present: usually if `CANONICAL` is not present (e.g. the parameter key for `FILTER a == 1`), there is an info node
1905
+ * for `FILTER condition:a == 1`. This `condition:` was neither written by the user nor is it canonical; but it might be
1906
+ * used to help the user understand what this parameter means.
1907
+ *
1908
+ * @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.
1909
+ *
1910
+ * @example <caption>Code example</caption>
1911
+ * import { queryAssistanceClient } from "@dynatrace-sdk/client-query";
1912
+ *
1913
+ * const data = await queryAssistanceClient.queryParse({
1914
+ * body: {
1915
+ * query:
1916
+ * 'fetch events | filter event.type == "davis" AND davis.status != "CLOSED" | fields timestamp, davis.title, davis.underMaintenance, davis.status | sort timestamp | limit 10',
1917
+ * },
1918
+ * });
1919
+ */
1686
1920
  async queryParse(config) {
1687
1921
  if (!config) {
1688
1922
  throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
@@ -1788,6 +2022,57 @@ var QueryAssistanceClient = class {
1788
2022
  }
1789
2023
  }
1790
2024
  }
2025
+ /**
2026
+ * Get a structured list of suggestions for the query at the given position.
2027
+ *
2028
+ * For information about the required permissions see the [Bucket and table permissions in Grail documentation](https://docs.dynatrace.com/docs/shortlink/assign-bucket-table-permissions).
2029
+ *
2030
+ * ## Overview
2031
+ *
2032
+ * We provide a list of suggestions that may be used after the cursor position. The following queries will all provide the
2033
+ * same results:
2034
+ *
2035
+ * * `query: "f"`
2036
+ * * `query: "f", cursorPosition:1`
2037
+ * * `query: "fetch ", cursorPosition:1`
2038
+ *
2039
+ * Available fields:
2040
+ *
2041
+ * | Field | Description |
2042
+ * |-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2043
+ * | suggestions | a list of suggestions. Each item is a separate possible suggestion, despite they might have the same outputs. |
2044
+ * | 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. |
2045
+ *
2046
+ * Fields in the `suggestions`
2047
+ *
2048
+ * | Field | Description |
2049
+ * |------------------------|------------------------------------------------------------------------------------------------------------|
2050
+ * | suggestion | a string representing the whole suggestion. This information could also be derived from the parts. |
2051
+ * | alreadyTypedCharacters | how many characters of this suggestion have already been typed (and will be overridden by the suggestion). |
2052
+ * | parts | a list of semantically enriched information on what are the parts of a suggestion. |
2053
+ *
2054
+ * Fields in `parts`
2055
+ *
2056
+ * | Field | Description |
2057
+ * |------------|-----------------------------------------------------------|
2058
+ * | suggestion | a string representing the current part of the suggestion. |
2059
+ * | type | current types: SPACE, PIPE, COMMAND (may be extended) |
2060
+ *
2061
+ * The `type` helps to treat specific parts of the suggestion different to others; either by a different visualization,
2062
+ * a link to docs, etc.
2063
+ *
2064
+ * @returns A list of structured autocomplete suggestions.
2065
+ *
2066
+ * @example <caption>Code example</caption>
2067
+ * import { queryAssistanceClient } from "@dynatrace-sdk/client-query";
2068
+ *
2069
+ * const data = await queryAssistanceClient.queryAutocomplete({
2070
+ * body: {
2071
+ * query:
2072
+ * 'fetch events | filter event.type == "davis" AND davis.status != "CLOSED" | fields timestamp, davis.title, davis.underMaintenance, davis.status | sort timestamp | limit 10',
2073
+ * },
2074
+ * });
2075
+ */
1791
2076
  async queryAutocomplete(config) {
1792
2077
  if (!config) {
1793
2078
  throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
@@ -3233,10 +3518,60 @@ var toQueryString = (rawQuery, flags = {}) => {
3233
3518
  // packages/client/query/src/lib/apis/query-execution-api.ts
3234
3519
  var QueryExecutionClient = class {
3235
3520
  httpClient;
3521
+ /**
3522
+ * @param {HttpClient} httpClientImplementation - You can provide custom http client as a parameter to constructor of a QueryExecutionClient. Custom http client should implement {HttpClient} interface.
3523
+ * @example
3524
+ * const queryExecutionClientNodeJs = new QueryExecutionClient(yourCustomImplementation);
3525
+ */
3236
3526
  constructor(httpClientImplementation) {
3237
3527
  this.httpClient = httpClientImplementation;
3238
3528
  registerGlobalErrorSerializer(apiClientErrorSerializer);
3239
3529
  }
3530
+ /**
3531
+ * Retrieves query status and final result from Grail.
3532
+ *
3533
+ * For information about the required permissions see the [Bucket and table permissions in Grail documentation](https://docs.dynatrace.com/docs/shortlink/assign-bucket-table-permissions).
3534
+ *
3535
+ * ### Overview:
3536
+ *
3537
+ * Polls the status of a Grail query. Returns the status of the query, including the result if the query finished.
3538
+ *
3539
+ * ### The response format:
3540
+ * The json response will contain the state of the query. If the query succeeded, the result will be included.
3541
+ *
3542
+ * The result has two main sections:
3543
+ * * The 'records' section contains the individual records, where each record consists of a set of fields and their corresponding values.
3544
+ * * The 'types' section describes the corresponding data types that a record field has.
3545
+ *
3546
+ * Every record has an implicit 'index' according to the position in the 'records' JSON array.
3547
+ * The types section has a list of 1..N possible type 'buckets'. Each such bucket has an 'indexRange' which indicates which
3548
+ * 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).
3549
+ *
3550
+ * A field part of a record with index 'i' will find its corresponding field type by first locating the bucket that satisfies:
3551
+ *
3552
+ * ```text
3553
+ * startIndex <= i <= endIndex
3554
+ * ```
3555
+ *
3556
+ * Once the bucket is found the 'mappings' object has an entry for all the fields that are part of that record with index 'i'.
3557
+ *
3558
+ *
3559
+ * Since enforcement of a particular schema is absent at ingestion time, it is possible to have records that share the same
3560
+ * field name but their values are of a different type. This phenomenon will hence forth be named as a **"collision"**.
3561
+ * When a collision does occur, we will create a new type 'bucket' that will have a different index range where
3562
+ * the new record field types will be placed.
3563
+ * It is guaranteed that every field of every record will have a corresponding type.
3564
+ * **Clients should always take the included types into account when consuming records!**
3565
+ *
3566
+ * @returns The current status and results of the supplied query.
3567
+ *
3568
+ * @example <caption>Code example</caption>
3569
+ * import { queryExecutionClient } from "@dynatrace-sdk/client-query";
3570
+ *
3571
+ * const data = await queryExecutionClient.queryPoll({
3572
+ * requestToken: "...",
3573
+ * });
3574
+ */
3240
3575
  async queryPoll(config) {
3241
3576
  if (!config) {
3242
3577
  throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
@@ -3304,7 +3639,10 @@ var QueryExecutionClient = class {
3304
3639
  }
3305
3640
  }
3306
3641
  case 410: {
3307
- const responseValue = await response.body("text");
3642
+ const responseValue = await response.body(
3643
+ "text"
3644
+ /* type from spec unsupported */
3645
+ );
3308
3646
  throw new ClientRequestError(
3309
3647
  `410`,
3310
3648
  response,
@@ -3349,6 +3687,57 @@ var QueryExecutionClient = class {
3349
3687
  }
3350
3688
  }
3351
3689
  }
3690
+ /**
3691
+ * Starts a Grail query.
3692
+ *
3693
+ * For information about the required permissions see the [Bucket and table permissions in Grail documentation](https://docs.dynatrace.com/docs/shortlink/assign-bucket-table-permissions).
3694
+ *
3695
+ * ### Overview:
3696
+ *
3697
+ * Executes a query and returns a list of records.
3698
+ *
3699
+ * For details about the query language see the [Dynatrace Query Language documentation](https://dt-url.net/bv03yk8).
3700
+ *
3701
+ * ### The response format:
3702
+ *
3703
+ * The json response will contain the state of the started query. If the query succeeded, the result will be included. Otherwise the response will contain a request token to reference the query in future polling requests.
3704
+ *
3705
+ * The result has two main sections:
3706
+ * * The 'records' section contains the individual records, where each record consists of a set of fields and their corresponding values.
3707
+ * * The 'types' section describes the corresponding data types that a record field has.
3708
+ *
3709
+ * Every record has an implicit 'index' according to the position in the 'records' JSON array.
3710
+ * The types section has a list of 1..N possible type 'buckets'. Each such bucket has an 'indexRange' which indicates which
3711
+ * 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).
3712
+ *
3713
+ * A field part of a record with index 'i' will find its corresponding field type by first locating the bucket that satisfies:
3714
+ *
3715
+ * ```text
3716
+ * startIndex <= i <= endIndex
3717
+ * ```
3718
+ *
3719
+ * Once the bucket is found the 'mappings' object has an entry for all the fields that are part of that record with index 'i'.
3720
+ *
3721
+ *
3722
+ * Since enforcement of a particular schema is absent at ingestion time, it is possible to have records that share the same
3723
+ * field name but their values are of a different type. This phenomenon will hence forth be named as a **"collision"**.
3724
+ * When a collision does occur, we will create a new type 'bucket' that will have a different index range where
3725
+ * the new record field types will be placed.
3726
+ * It is guaranteed that every field of every record will have a corresponding type.
3727
+ * **Clients should always take the included types into account when consuming records!**
3728
+ *
3729
+ * @returns The final status and results of the supplied query if it finished within a supplied requestTimeoutMilliseconds. | The status of the query to start.
3730
+ *
3731
+ * @example <caption>Code example</caption>
3732
+ * import { queryExecutionClient } from "@dynatrace-sdk/client-query";
3733
+ *
3734
+ * const data = await queryExecutionClient.queryExecute({
3735
+ * body: {
3736
+ * query:
3737
+ * 'fetch events | filter event.type == "davis" AND davis.status != "CLOSED" | fields timestamp, davis.title, davis.underMaintenance, davis.status | sort timestamp | limit 10',
3738
+ * },
3739
+ * });
3740
+ */
3352
3741
  async queryExecute(config) {
3353
3742
  if (!config) {
3354
3743
  throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
@@ -3604,6 +3993,53 @@ var QueryExecutionClient = class {
3604
3993
  }
3605
3994
  }
3606
3995
  }
3996
+ /**
3997
+ * Cancels the query and returns the result if the query was already finished, otherwise discards it.
3998
+ *
3999
+ * For information about the required permissions see the [Bucket and table permissions in Grail documentation](https://docs.dynatrace.com/docs/shortlink/assign-bucket-table-permissions).
4000
+ *
4001
+ * ### Overview:
4002
+ *
4003
+ * Cancels a running Grail query and returns a list of records if the query already finished.
4004
+ *
4005
+ * ### The response format:
4006
+ *
4007
+ * If the query was already finished, a response body including the result will be returned. Otherwise the response will contain no body.
4008
+ *
4009
+ * The result has three main sections:
4010
+ * * the 'records' section contains the individual records, where each record consists of a set of fields and their corresponding values.
4011
+ * * the 'types' section describes the corresponding data types that a record field has.
4012
+ * * the 'metadata' section contains information about the query like 'analysisTimeframe', 'timezone' or 'locale'.
4013
+ *
4014
+ * Every record has an implicit 'index' according to the position in the 'records' JSON array.
4015
+ * The types section has a list of 1..N possible type 'buckets'. Each such bucket has an 'indexRange' which indicates which
4016
+ * 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).
4017
+ *
4018
+ * A field part of a record with index 'i' will find its corresponding field type by first locating the bucket that satisfies:
4019
+ *
4020
+ * ```text
4021
+ * startIndex <= i <= endIndex
4022
+ * ```
4023
+ *
4024
+ * Once the bucket is found the 'mappings' object has an entry for all the fields that are part of that record with index 'i'.
4025
+ *
4026
+ *
4027
+ * Since enforcement of a particular schema is absent at ingestion time, it is possible to have records that share the same
4028
+ * field name but their values are of a different type. This phenomenon will hence forth be named as a **"collision"**.
4029
+ * When a collision does occur, we will create a new type 'bucket' that will have a different index range where
4030
+ * the new record field types will be placed.
4031
+ * It is guaranteed that every field of every record will have a corresponding type.
4032
+ * **Clients should always take the included types into account when consuming records!**
4033
+ *
4034
+ * @returns The query already finished.
4035
+ *
4036
+ * @example <caption>Code example</caption>
4037
+ * import { queryExecutionClient } from "@dynatrace-sdk/client-query";
4038
+ *
4039
+ * const data = await queryExecutionClient.queryCancel({
4040
+ * requestToken: "...",
4041
+ * });
4042
+ */
3607
4043
  async queryCancel(config) {
3608
4044
  if (!config) {
3609
4045
  throw new ApiClientError("API client error", "API client call is missing mandatory config parameter");
@@ -3689,7 +4125,10 @@ var QueryExecutionClient = class {
3689
4125
  }
3690
4126
  }
3691
4127
  case 410: {
3692
- const responseValue = await response.body("text");
4128
+ const responseValue = await response.body(
4129
+ "text"
4130
+ /* type from spec unsupported */
4131
+ );
3693
4132
  throw new ClientRequestError(
3694
4133
  `410`,
3695
4134
  response,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynatrace-sdk/client-query",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "Exposes an API to fetch records stored in Grail.",
5
5
  "license": "Apache-2.0",
6
6
  "dependencies": {
@@ -1,5 +1,5 @@
1
1
  import { DQLNodeNodeType } from './dql-node-node-type';
2
- export declare type AsJson = string;
2
+ export type AsJson = string;
3
3
  export declare function isDqlNodeNodeType(value: any): value is DQLNodeNodeType;
4
4
  export declare function isJson(value: any): value is AsJson;
5
5
  export declare function fromJson($model: AsJson): DQLNodeNodeType;
@@ -1,5 +1,5 @@
1
1
  import { FieldTypeType } from './field-type-type';
2
- export declare type AsJson = string;
2
+ export type AsJson = string;
3
3
  export declare function isFieldTypeType(value: any): value is FieldTypeType;
4
4
  export declare function isJson(value: any): value is AsJson;
5
5
  export declare function fromJson($model: AsJson): FieldTypeType;
@@ -1,5 +1,5 @@
1
1
  import { QueryState } from './query-state';
2
- export declare type AsJson = string;
2
+ export type AsJson = string;
3
3
  export declare function isQueryState(value: any): value is QueryState;
4
4
  export declare function isJson(value: any): value is AsJson;
5
5
  export declare function fromJson($model: AsJson): QueryState;
@@ -5,4 +5,4 @@ import { Timeframe } from '../models/timeframe';
5
5
  * Single result field of a record.
6
6
  * @typedef {boolean | number | string | Timeframe | GeoPoint | ResultRecord | null | (ResultRecordValue | null)[] | null} ResultRecordValue
7
7
  */
8
- export declare type ResultRecordValue = boolean | number | string | Timeframe | GeoPoint | ResultRecord | null | (ResultRecordValue | null)[] | null;
8
+ export type ResultRecordValue = boolean | number | string | Timeframe | GeoPoint | ResultRecord | null | (ResultRecordValue | null)[] | null;
@@ -6,7 +6,7 @@ import { Timeframe } from '../models/timeframe';
6
6
  import * as _TimeframeTransformation from '../models/timeframe.transformation';
7
7
  import { ResultRecordValue } from './result-record-value';
8
8
  import * as _ResultRecordValueTransformation from './result-record-value.transformation';
9
- export declare type AsJson = boolean | number | string | _TimeframeTransformation.AsJson | _GeoPointTransformation.AsJson | _ResultRecordTransformation.AsJson | null | (_ResultRecordValueTransformation.AsJson | null)[] | null;
9
+ export type AsJson = boolean | number | string | _TimeframeTransformation.AsJson | _GeoPointTransformation.AsJson | _ResultRecordTransformation.AsJson | null | (_ResultRecordValueTransformation.AsJson | null)[] | null;
10
10
  export declare function checkBoolean(value: any): value is boolean;
11
11
  export declare function checkNumber(value: any): value is number;
12
12
  export declare function checkString(value: any): value is string;
@@ -1,5 +1,5 @@
1
1
  import { TokenType } from './token-type';
2
- export declare type AsJson = string;
2
+ export type AsJson = string;
3
3
  export declare function isTokenType(value: any): value is TokenType;
4
4
  export declare function isJson(value: any): value is AsJson;
5
5
  export declare function fromJson($model: AsJson): TokenType;
@@ -1,4 +1,4 @@
1
- declare type QueryParamsType = Record<string | number, any>;
1
+ type QueryParamsType = Record<string | number, any>;
2
2
  interface ParametersFlags {
3
3
  explode?: Record<string, boolean>;
4
4
  }
@@ -2,5 +2,5 @@ import * as types from '../types';
2
2
  declare const AbortController: {
3
3
  new (): types.AbortController;
4
4
  };
5
- declare type AbortController = InstanceType<typeof AbortController>;
5
+ type AbortController = InstanceType<typeof AbortController>;
6
6
  export { AbortController };
@@ -2,5 +2,5 @@ import * as types from '../types';
2
2
  declare const AbortSignal: {
3
3
  new (): types.AbortSignal;
4
4
  };
5
- declare type AbortSignal = InstanceType<typeof AbortSignal>;
5
+ type AbortSignal = InstanceType<typeof AbortSignal>;
6
6
  export { AbortSignal };
@@ -0,0 +1,48 @@
1
+ export declare function isTextContentType(contentType: string): boolean;
2
+ export declare function parseContentDisposition(contentDisposition: string): {
3
+ name: string;
4
+ fileName: string | undefined;
5
+ };
6
+ export declare function parseFormDataBoundary(contentType: string): string | undefined;
7
+ export interface FormDataSection {
8
+ name: string;
9
+ headers: Record<string, string>;
10
+ rawData: Uint8Array;
11
+ text?: string;
12
+ file?: File;
13
+ fileName?: string;
14
+ payloadStartOffset?: number;
15
+ payloadEndOffset?: number;
16
+ headersStartOffset?: number;
17
+ }
18
+ export declare class FormDataParser {
19
+ private sourceArray;
20
+ private boundary;
21
+ private currentChar;
22
+ private currentByte;
23
+ offset: number;
24
+ private utf8Decoder;
25
+ constructor(sourceArray: Uint8Array, boundary: string);
26
+ get previousByte(): number | undefined;
27
+ get previousChar(): string | undefined;
28
+ private next;
29
+ charAt(offset: number): string | null;
30
+ nextChar(): string | null;
31
+ nextByte(): number | null;
32
+ get nextTwoChars(): string;
33
+ findNextBoundaryOffset(startOffset?: number): number | null;
34
+ skipPastNextBoundary(): boolean;
35
+ readLine(): Uint8Array | null;
36
+ readSectionHeaders(): {
37
+ headersLength: number;
38
+ headers: Record<string, string>;
39
+ };
40
+ extractData(): {
41
+ payloadStartOffset: number;
42
+ payloadEndOffset: number;
43
+ data: Uint8Array;
44
+ };
45
+ parse(): FormDataSection[];
46
+ }
47
+ export declare function isAppleBrowser(): boolean;
48
+ export declare function parseMultipartFormDataResponse(response: Uint8Array, boundary: string): FormDataSection[];
@@ -1,15 +1,23 @@
1
1
  import * as types from '../types';
2
+ import { Headers } from '../types';
2
3
  interface HttpClientConfiguration {
3
4
  baseUrl?: string;
5
+ defaultHeaders?: Headers;
4
6
  }
5
7
  export declare class HttpClient implements types.HttpClient {
6
8
  private _baseUrl;
9
+ private _defaultHeaders;
7
10
  constructor(options?: HttpClientConfiguration);
8
11
  /**
9
12
  * Sets HTTP Client Instance baseUrl param to the incoming value `baseUrl`.
10
13
  * @param baseUrl Base URL used in the request path.
11
14
  */
12
15
  _setBaseURL(baseUrl: string): void;
16
+ /**
17
+ * Sets HTTP Client Instance defaultHeaders param to the incoming value `defaultHeaders`.
18
+ * @param defaultHeaders HTTP Headers to be used in outgoing requests.
19
+ */
20
+ _setDefaultHeaders(defaultHeaders: Headers): void;
13
21
  send<T extends keyof types.RequestBodyTypes = 'json'>(options: types.HttpClientRequestOptions<T>): Promise<types.HttpClientResponse>;
14
22
  }
15
23
  export declare const httpClient: HttpClient;
@@ -4,7 +4,7 @@ import type * as stream from 'stream';
4
4
  /**
5
5
  * Mapping between the data type names and types.
6
6
  */
7
- export declare type DataTypes = {
7
+ export type DataTypes = {
8
8
  /**
9
9
  * A text type.
10
10
  */