@dynatrace-sdk/client-query 1.20.0 → 1.21.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 (26) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +15 -12
  3. package/cjs/index.js +157 -342
  4. package/dynatrace-metadata.json +3 -4
  5. package/esm/index.js +64 -236
  6. package/package.json +2 -2
  7. package/types/packages/client/query/src/lib/apis/query-assistance-api.d.ts +2 -2
  8. package/types/packages/client/query/src/lib/apis/query-execution-api.d.ts +2 -2
  9. package/types/packages/client/query/src/lib/models/autocomplete-request.d.ts +4 -0
  10. package/types/packages/client/query/src/lib/models/autocomplete-suggestion-part.d.ts +1 -1
  11. package/types/packages/client/query/src/lib/models/dql-terminal-node.d.ts +1 -1
  12. package/types/packages/client/query/src/lib/models/error-response.d.ts +4 -0
  13. package/types/packages/client/query/src/lib/models/execute-request.d.ts +4 -0
  14. package/types/packages/client/query/src/lib/models/token-type.d.ts +9 -1
  15. package/types/packages/{client/query/src/lib/apis → shared-client-utils/src}/api-client-options.d.ts +1 -1
  16. package/types/packages/shared-client-utils/src/api-gateway-errors-handler.d.ts +9 -0
  17. package/types/packages/shared-client-utils/src/encoding.d.ts +17 -0
  18. package/types/packages/shared-client-utils/src/get-error-message.d.ts +8 -0
  19. package/types/packages/shared-client-utils/src/index.d.ts +6 -0
  20. package/types/packages/shared-client-utils/src/transformations.d.ts +64 -0
  21. package/types/packages/shared-client-utils/src/url-helpers.d.ts +12 -0
  22. package/types/packages/client/query/src/lib/error-envelopes/api-gateway-errors-handler.d.ts +0 -2
  23. package/types/packages/client/query/src/lib/error-envelopes/get-error-message.d.ts +0 -1
  24. package/types/packages/client/query/src/lib/utils/encoding.d.ts +0 -10
  25. package/types/packages/client/query/src/lib/utils/transformations.d.ts +0 -7
  26. package/types/packages/client/query/src/lib/utils/url-helpers.d.ts +0 -6
@@ -6,7 +6,7 @@ export interface DQLTerminalNode extends DQLNode {
6
6
  /**
7
7
  * The type of the autocomplete token.
8
8
  */
9
- type?: 'SPACE' | 'LINEBREAK' | 'INDENT' | 'PIPE' | 'DOT' | 'COLON' | 'COMMA' | 'ASSIGNMENT' | 'BRACE_OPEN' | 'BRACE_CLOSE' | 'BRACKET_OPEN' | 'BRACKET_CLOSE' | 'PARENTHESIS_OPEN' | 'PARENTHESIS_CLOSE' | 'QUOTE' | 'SINGLE_QUOTE' | 'SLASH' | 'BOOLEAN_TRUE' | 'BOOLEAN_FALSE' | 'NULL' | 'COMMAND_NAME' | 'PARAMETER_KEY' | 'PARAMETER_VALUE_SCOPE' | 'FUNCTION_NAME' | 'TIMESERIES_AGGREGATION' | 'TIMESERIES_AGGREGATION_EXPRESSION' | 'OPERATOR' | 'SEARCH_OPERATOR' | 'TRAVERSAL_OPERATOR' | 'TRAVERSAL_RELATION_NAME' | 'TRAVERSAL_HOP_COUNT' | 'SIMPLE_IDENTIFIER' | 'DATA_OBJECT' | 'NUMBER' | 'STRING' | 'TIME_UNIT' | 'TIMESTAMP_VALUE' | 'METRIC_KEY' | 'VARIABLE' | 'END_COMMENT' | 'UID_VALUE' | 'PARSE_PATTERN' | 'FIELD_PATTERN' | 'SEARCH_PATTERN' | 'ENTITY_SELECTOR_PART' | 'SAVED_TABLE_NAME' | 'PARAMETER_MODIFIER' | 'FIELD_MODIFIER' | 'ENTITY_TYPE' | 'ENTITY_ATTRIBUTE' | 'SMARTSCAPE_ID_VALUE';
9
+ type?: 'SPACE' | 'LINEBREAK' | 'INDENT' | 'PIPE' | 'DOT' | 'COLON' | 'COMMA' | 'ASSIGNMENT' | 'BRACE_OPEN' | 'BRACE_CLOSE' | 'BRACKET_OPEN' | 'BRACKET_CLOSE' | 'PARENTHESIS_OPEN' | 'PARENTHESIS_CLOSE' | 'QUOTE' | 'SINGLE_QUOTE' | 'SLASH' | 'BOOLEAN_TRUE' | 'BOOLEAN_FALSE' | 'NULL' | 'COMMAND_NAME' | 'PARAMETER_KEY' | 'PARAMETER_VALUE_SCOPE' | 'FUNCTION_NAME' | 'TIMESERIES_AGGREGATION' | 'TIMESERIES_AGGREGATION_EXPRESSION' | 'OPERATOR' | 'SEARCH_OPERATOR' | 'TRAVERSAL_OPERATOR' | 'TRAVERSAL_RELATION_NAME' | 'TRAVERSAL_HOP_COUNT' | 'SIMPLE_IDENTIFIER' | 'DATA_OBJECT' | 'NUMBER' | 'STRING' | 'TIME_UNIT' | 'TIMESTAMP_VALUE' | 'METRIC_KEY' | 'VARIABLE' | 'END_COMMENT' | 'UID_VALUE' | 'PARSE_PATTERN' | 'FIELD_PATTERN' | 'SEARCH_PATTERN' | 'ENTITY_SELECTOR_PART' | 'SAVED_TABLE_NAME' | 'TABULAR_FILE_NAME' | 'PARAMETER_MODIFIER' | 'FIELD_MODIFIER' | 'ENTITY_TYPE' | 'ENTITY_ATTRIBUTE' | 'SMARTSCAPE_ID_VALUE' | 'ENUM_STRING' | 'FIELD_PREFIX' | 'BUCKET' | 'SMARTSCAPE_NODE_PATTERN' | 'SMARTSCAPE_EDGE_PATTERN' | 'SMARTSCAPE_NODE_TYPE' | 'SMARTSCAPE_EDGE_TYPE';
10
10
  /**
11
11
  * For optional items only: whether this node becomes mandatory when user order is used. True only for some optional 'ghost braces'
12
12
  */
@@ -15,4 +15,8 @@ export interface ErrorResponse {
15
15
  * Error code, which normally matches the HTTP error code.
16
16
  */
17
17
  code: number;
18
+ /**
19
+ * The number of seconds to wait until the next retry.
20
+ */
21
+ retryAfterSeconds?: number;
18
22
  }
@@ -61,4 +61,8 @@ export interface ExecuteRequest {
61
61
  * Parameter to exclude the type information from the query result. In case not specified, the type information will be included.
62
62
  */
63
63
  includeTypes?: boolean;
64
+ /**
65
+ * Boolean to indicate if the query consumption limit should be enforced
66
+ */
67
+ enforceQueryConsumptionLimit?: boolean;
64
68
  }
@@ -50,9 +50,17 @@ export declare enum TokenType {
50
50
  SearchPattern = "SEARCH_PATTERN",
51
51
  EntitySelectorPart = "ENTITY_SELECTOR_PART",
52
52
  SavedTableName = "SAVED_TABLE_NAME",
53
+ TabularFileName = "TABULAR_FILE_NAME",
53
54
  ParameterModifier = "PARAMETER_MODIFIER",
54
55
  FieldModifier = "FIELD_MODIFIER",
55
56
  EntityType = "ENTITY_TYPE",
56
57
  EntityAttribute = "ENTITY_ATTRIBUTE",
57
- SmartscapeIdValue = "SMARTSCAPE_ID_VALUE"
58
+ SmartscapeIdValue = "SMARTSCAPE_ID_VALUE",
59
+ EnumString = "ENUM_STRING",
60
+ FieldPrefix = "FIELD_PREFIX",
61
+ Bucket = "BUCKET",
62
+ SmartscapeNodePattern = "SMARTSCAPE_NODE_PATTERN",
63
+ SmartscapeEdgePattern = "SMARTSCAPE_EDGE_PATTERN",
64
+ SmartscapeNodeType = "SMARTSCAPE_NODE_TYPE",
65
+ SmartscapeEdgeType = "SMARTSCAPE_EDGE_TYPE"
58
66
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Configuration for generated TypeScript SDK clients
2
+ * Configuration for the API client.
3
3
  * @param {boolean} transformDates - Flag to control date transformations, enabled by default.
4
4
  */
5
5
  export interface ApiClientOptions {
@@ -0,0 +1,9 @@
1
+ import type { HttpClientResponse } from '@dynatrace-sdk/http-client';
2
+ /**
3
+ * Handles errors from API Gateway responses.
4
+ * Throws an ApiGatewayError if the response source is 'API Gateway'.
5
+ *
6
+ * @param {HttpClientResponse} response - The HTTP response to check for API Gateway errors.
7
+ * @throws {ApiGatewayError} If the response is from API Gateway and contains an error.
8
+ */
9
+ export declare function apiGatewayErrorsHandler(response: HttpClientResponse): Promise<void>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Available formats to transform models to and from
3
+ */
4
+ export declare enum Encoding {
5
+ Json = "json",
6
+ Text = "text",
7
+ Binary = "binary",
8
+ FormData = "form-data"
9
+ }
10
+ /**
11
+ * Maps a MIME type string to an Encoding.
12
+ *
13
+ * @param {string} mimeType - The MIME type to convert (e.g., 'application/json').
14
+ * @param {Encoding} [defaultEncoding] - The encoding to return if the MIME type isn't recognized.
15
+ * @returns {Encoding} The corresponding Encoding enum value, or the defaultEncoding if not recognized.
16
+ */
17
+ export declare function mimeTypeToEncoding(mimeType: string, defaultEncoding?: Encoding): Encoding;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns a user-friendly error message from an error body object.
3
+ *
4
+ * @param {unknown} errorBody - The error object or response body to extract the message from.
5
+ * @param {string} defaultMessage - The default message to use if no error message is found.
6
+ * @returns {string} The extracted or default error message, possibly including details.
7
+ */
8
+ export declare function getErrorMessage(errorBody: unknown, defaultMessage: string): string;
@@ -0,0 +1,6 @@
1
+ export * from './api-client-options';
2
+ export * from './api-gateway-errors-handler';
3
+ export * from './encoding';
4
+ export * from './get-error-message';
5
+ export * from './transformations';
6
+ export * from './url-helpers';
@@ -0,0 +1,64 @@
1
+ import { FormDataRequestBody, FormDataRequestField, FormDataResponseBody } from '@dynatrace-sdk/http-client';
2
+ export type TransformRuleConfig = {
3
+ force?: boolean;
4
+ datetime?: boolean;
5
+ };
6
+ export type TransformRulesParam = Array<string | [string, TransformRuleConfig]>;
7
+ /**
8
+ * Transforms an object by applying transformation rules before sending it in a request.
9
+ *
10
+ * @template T
11
+ * @param {T} object - The object to transform.
12
+ * @param {TransformRulesParam} rules - The transformation rules to apply.
13
+ * @returns {T} The transformed object.
14
+ */
15
+ export declare function transformRequest<T = any>(object: T, rules: TransformRulesParam): T;
16
+ /**
17
+ * Transforms an object by applying transformation rules after receiving it in a response.
18
+ *
19
+ * @template T
20
+ * @param {T} object - The object to transform.
21
+ * @param {TransformRulesParam} rules - The transformation rules to apply.
22
+ * @returns {T} The transformed object.
23
+ */
24
+ export declare function transformResponse<T = any>(object: T, rules: TransformRulesParam): T;
25
+ export interface FormDataRequestFieldDefinition {
26
+ key: string;
27
+ type: 'text' | 'json' | 'binary';
28
+ required: boolean;
29
+ }
30
+ export interface FormDataResponseGenericFieldDefinition {
31
+ type: 'text' | 'binary';
32
+ }
33
+ export interface FormDataResponseJsonFieldDefinition {
34
+ type: 'json';
35
+ transformations: Array<string | [string, TransformRuleConfig]>;
36
+ }
37
+ export type FormDataResponseFieldDefinition = FormDataResponseGenericFieldDefinition | FormDataResponseJsonFieldDefinition;
38
+ /**
39
+ * Converts an object to a FormDataRequestBody using field definitions.
40
+ *
41
+ * @template T
42
+ * @param {T} value - The object to convert.
43
+ * @param {Array<FormDataRequestFieldDefinition>} fields - The field definitions for the form data.
44
+ * @returns {FormDataRequestBody} The resulting form data body.
45
+ */
46
+ export declare function transformToFormData<T extends Record<any, any>>(value: T, fields: Array<FormDataRequestFieldDefinition>): FormDataRequestBody;
47
+ /**
48
+ * Converts a value to a FormDataRequestField based on the field definition.
49
+ *
50
+ * @template T
51
+ * @param {T} value - The value to convert.
52
+ * @param {FormDataRequestFieldDefinition} field - The field definition.
53
+ * @returns {FormDataRequestField | null} The resulting form data field or null if not required and undefined.
54
+ */
55
+ export declare function transformToFormDataField<T = any>(value: T, field: FormDataRequestFieldDefinition): FormDataRequestField | null;
56
+ /**
57
+ * Converts form data and field definitions into a typed object, applying transformations for JSON fields.
58
+ *
59
+ * @template T
60
+ * @param {FormDataResponseBody} formData - The form data to convert.
61
+ * @param {Record<string, FormDataResponseFieldDefinition>} fields - The field definitions for the form data.
62
+ * @returns {T} The resulting typed object.
63
+ */
64
+ export declare function transformFromFormData<T extends Record<any, any>>(formData: FormDataResponseBody, fields: Record<string, FormDataResponseFieldDefinition>): T;
@@ -0,0 +1,12 @@
1
+ export type QueryParamsType = Record<string | number, any>;
2
+ export interface ParametersFlags {
3
+ explode?: Record<string, boolean>;
4
+ }
5
+ /**
6
+ * Converts an object of query parameters into a URL query string.
7
+ *
8
+ * @param {QueryParamsType} [rawQuery] - The object containing query parameters.
9
+ * @param {ParametersFlags} [flags] - Flags to control parameter formatting (e.g., explode arrays).
10
+ * @returns {string} The resulting query string.
11
+ */
12
+ export declare const toQueryString: (rawQuery?: QueryParamsType, flags?: ParametersFlags) => string;
@@ -1,2 +0,0 @@
1
- import { HttpClientResponse } from '@dynatrace-sdk/http-client';
2
- export declare function apiGatewayErrorsHandler(response: HttpClientResponse): Promise<void>;
@@ -1 +0,0 @@
1
- export declare function getErrorMessage(errorBody: unknown, defaultMessage: string): string;
@@ -1,10 +0,0 @@
1
- /**
2
- * Available formats to transform models to and from
3
- */
4
- export declare enum Encoding {
5
- Json = "json",
6
- Text = "text",
7
- Binary = "binary",
8
- FormData = "form-data"
9
- }
10
- export declare function mimeTypeToEncoding(mimeType: string, defaultEncoding?: Encoding): Encoding;
@@ -1,7 +0,0 @@
1
- type TransformRuleConfig = {
2
- force?: boolean;
3
- datetime?: boolean;
4
- };
5
- export declare function transformRequest<T = any>(object: T, keys: Array<string | [string, TransformRuleConfig]>): T;
6
- export declare function transformResponse<T = any>(object: T, keys: Array<string | [string, TransformRuleConfig]>): T;
7
- export {};
@@ -1,6 +0,0 @@
1
- type QueryParamsType = Record<string | number, any>;
2
- interface ParametersFlags {
3
- explode?: Record<string, boolean>;
4
- }
5
- export declare const toQueryString: (rawQuery?: QueryParamsType, flags?: ParametersFlags) => string;
6
- export {};