@dynatrace-sdk/client-query 1.0.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 +9 -0
- package/LICENSE +174 -0
- package/README.md +54 -0
- package/cjs/index.js +1788 -0
- package/docs/DOCS.md +2833 -0
- package/dynatrace-metadata.json +18 -0
- package/esm/index.js +1766 -0
- package/package.json +11 -0
- package/types/index.d.ts +1 -0
- package/types/packages/client/query/src/index.d.ts +1 -0
- package/types/packages/client/query/src/lib/apis/index.d.ts +2 -0
- package/types/packages/client/query/src/lib/apis/query-assistance-api.d.ts +276 -0
- package/types/packages/client/query/src/lib/apis/query-execution-api.d.ts +337 -0
- package/types/packages/client/query/src/lib/error-envelopes/api-client-error.d.ts +9 -0
- package/types/packages/client/query/src/lib/error-envelopes/client-request-error.d.ts +8 -0
- package/types/packages/client/query/src/lib/error-envelopes/error-envelope-error.d.ts +8 -0
- package/types/packages/client/query/src/lib/error-envelopes/error-serializer.d.ts +3 -0
- package/types/packages/client/query/src/lib/error-envelopes/index.d.ts +3 -0
- package/types/packages/client/query/src/lib/error-envelopes/invalid-response-error.d.ts +8 -0
- package/types/packages/client/query/src/lib/index.d.ts +3 -0
- package/types/packages/client/query/src/lib/models/autocomplete-request.d.ts +26 -0
- package/types/packages/client/query/src/lib/models/autocomplete-response.d.ts +28 -0
- package/types/packages/client/query/src/lib/models/autocomplete-suggestion-part.d.ts +30 -0
- package/types/packages/client/query/src/lib/models/autocomplete-suggestion.d.ts +28 -0
- package/types/packages/client/query/src/lib/models/dql-alternative-node.d.ts +18 -0
- package/types/packages/client/query/src/lib/models/dql-container-node.d.ts +23 -0
- package/types/packages/client/query/src/lib/models/dql-node-node-type.d.ts +14 -0
- package/types/packages/client/query/src/lib/models/dql-node.d.ts +29 -0
- package/types/packages/client/query/src/lib/models/dql-terminal-node.d.ts +26 -0
- package/types/packages/client/query/src/lib/models/error-envelope.d.ts +18 -0
- package/types/packages/client/query/src/lib/models/error-response-details.d.ts +50 -0
- package/types/packages/client/query/src/lib/models/error-response.d.ts +25 -0
- package/types/packages/client/query/src/lib/models/execute-request.d.ts +64 -0
- package/types/packages/client/query/src/lib/models/field-type-type.d.ts +21 -0
- package/types/packages/client/query/src/lib/models/field-type.d.ts +18 -0
- package/types/packages/client/query/src/lib/models/geo-point.d.ts +22 -0
- package/types/packages/client/query/src/lib/models/grail-metadata.d.ts +66 -0
- package/types/packages/client/query/src/lib/models/index.d.ts +35 -0
- package/types/packages/client/query/src/lib/models/metadata-notification.d.ts +45 -0
- package/types/packages/client/query/src/lib/models/metadata.d.ts +18 -0
- package/types/packages/client/query/src/lib/models/metric-metadata.d.ts +32 -0
- package/types/packages/client/query/src/lib/models/parse-request.d.ts +24 -0
- package/types/packages/client/query/src/lib/models/position-info.d.ts +27 -0
- package/types/packages/client/query/src/lib/models/query-poll-response.d.ts +28 -0
- package/types/packages/client/query/src/lib/models/query-result.d.ts +27 -0
- package/types/packages/client/query/src/lib/models/query-start-response.d.ts +33 -0
- package/types/packages/client/query/src/lib/models/query-state.d.ts +17 -0
- package/types/packages/client/query/src/lib/models/ranged-field-types-mappings.d.ts +15 -0
- package/types/packages/client/query/src/lib/models/ranged-field-types.d.ts +20 -0
- package/types/packages/client/query/src/lib/models/result-record-value.d.ts +13 -0
- package/types/packages/client/query/src/lib/models/result-record.d.ts +15 -0
- package/types/packages/client/query/src/lib/models/timeframe.d.ts +22 -0
- package/types/packages/client/query/src/lib/models/token-position.d.ts +20 -0
- package/types/packages/client/query/src/lib/models/token-type.d.ts +48 -0
- package/types/packages/client/query/src/lib/models/verify-request.d.ts +24 -0
- package/types/packages/client/query/src/lib/models/verify-response.d.ts +23 -0
- package/types/packages/client/query/src/lib/utils/url-helpers.d.ts +3 -0
- package/types/packages/http-client/src/index.d.ts +2 -0
- package/types/packages/http-client/src/lib/platform/abort-controller.d.ts +6 -0
- package/types/packages/http-client/src/lib/platform/abort-signal.d.ts +6 -0
- package/types/packages/http-client/src/lib/platform/apply-content-type-header.d.ts +2 -0
- package/types/packages/http-client/src/lib/platform/base-error.d.ts +5 -0
- package/types/packages/http-client/src/lib/platform/binary.d.ts +13 -0
- package/types/packages/http-client/src/lib/platform/data-type-error.d.ts +6 -0
- package/types/packages/http-client/src/lib/platform/decode-response-body.d.ts +3 -0
- package/types/packages/http-client/src/lib/platform/default-status-validator.d.ts +2 -0
- package/types/packages/http-client/src/lib/platform/encode-request-body.d.ts +2 -0
- package/types/packages/http-client/src/lib/platform/http-client-abort-error.d.ts +7 -0
- package/types/packages/http-client/src/lib/platform/http-client-request-error.d.ts +7 -0
- package/types/packages/http-client/src/lib/platform/http-client-response-error-serializer.d.ts +1 -0
- package/types/packages/http-client/src/lib/platform/http-client-response-error.d.ts +8 -0
- package/types/packages/http-client/src/lib/platform/http-client-response.d.ts +10 -0
- package/types/packages/http-client/src/lib/platform/http-client.d.ts +5 -0
- package/types/packages/http-client/src/lib/platform/index.d.ts +11 -0
- package/types/packages/http-client/src/lib/platform/unsupported-operation-error.d.ts +6 -0
- package/types/packages/http-client/src/lib/types/abort-controller.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/abort-signal.d.ts +15 -0
- package/types/packages/http-client/src/lib/types/base-error.d.ts +4 -0
- package/types/packages/http-client/src/lib/types/binary.d.ts +15 -0
- package/types/packages/http-client/src/lib/types/data-type-error.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/data-types.d.ts +36 -0
- package/types/packages/http-client/src/lib/types/form-data-request-body.d.ts +83 -0
- package/types/packages/http-client/src/lib/types/form-data-response-body.d.ts +15 -0
- package/types/packages/http-client/src/lib/types/headers.d.ts +6 -0
- package/types/packages/http-client/src/lib/types/http-client-abort-error.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/http-client-network-error.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/http-client-request-error.d.ts +14 -0
- package/types/packages/http-client/src/lib/types/http-client-request-options.d.ts +42 -0
- package/types/packages/http-client/src/lib/types/http-client-response-error.d.ts +19 -0
- package/types/packages/http-client/src/lib/types/http-client-response.d.ts +33 -0
- package/types/packages/http-client/src/lib/types/http-client.d.ts +24 -0
- package/types/packages/http-client/src/lib/types/index.d.ts +20 -0
- package/types/packages/http-client/src/lib/types/request-body-types.d.ts +26 -0
- package/types/packages/http-client/src/lib/types/response-body-types.d.ts +46 -0
- package/types/packages/http-client/src/lib/types/status-validator.d.ts +7 -0
- package/types/packages/http-client/src/lib/types/unsupported-operation-error.d.ts +14 -0
- package/types/packages/platform/error-handlers/src/index.d.ts +2 -0
- package/types/packages/platform/error-handlers/src/lib/add-global-error-serializer.d.ts +13 -0
- package/types/packages/platform/error-handlers/src/lib/types/common-serialized-error.d.ts +10 -0
- package/types/packages/platform/error-handlers/src/lib/types/dt-runtime-error-handlers.d.ts +5 -0
- package/types/packages/platform/error-handlers/src/lib/types/error-type.d.ts +9 -0
- package/types/packages/platform/error-handlers/src/lib/types/global-dt-runtime-with-error-handlers.d.ts +7 -0
- package/types/packages/platform/error-handlers/src/lib/types/global-error-serializer.d.ts +10 -0
- package/types/packages/platform/error-handlers/src/lib/types/http-serialized-error.d.ts +11 -0
- package/types/packages/platform/error-handlers/src/lib/types/index.d.ts +6 -0
- package/types/packages/platform/error-handlers/src/lib/types/serialized-error.d.ts +8 -0
- package/types/packages/platform/shared/index.d.ts +1 -0
- package/types/packages/platform/shared/utils/get-global-with-dt-runtime.d.ts +1 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type * as stream from 'stream';
|
|
4
|
+
import { Binary } from './binary';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a plain text field. No filename and content type is set.
|
|
7
|
+
*/
|
|
8
|
+
export interface TextFormDataRequestField {
|
|
9
|
+
/**
|
|
10
|
+
* A plain text field type discriminator.
|
|
11
|
+
*/
|
|
12
|
+
type: 'text';
|
|
13
|
+
/**
|
|
14
|
+
* The name of the field.
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* The field's value.
|
|
19
|
+
*/
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Represents a JSON field.
|
|
24
|
+
*/
|
|
25
|
+
export interface JsonFormDataRequestField {
|
|
26
|
+
/**
|
|
27
|
+
* A JSON field type discriminator.
|
|
28
|
+
*/
|
|
29
|
+
type: 'json';
|
|
30
|
+
/**
|
|
31
|
+
* The name of the field.
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
/**
|
|
35
|
+
* The content type of the data contained in `value`.
|
|
36
|
+
* The default content type for the JSON is 'application/json'.
|
|
37
|
+
*/
|
|
38
|
+
contentType?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The filename reported to the server.
|
|
41
|
+
* The default filename for the JSON is 'json'.
|
|
42
|
+
*/
|
|
43
|
+
filename?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The field's value.
|
|
46
|
+
*/
|
|
47
|
+
value: any;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Represents an binary field.
|
|
51
|
+
*/
|
|
52
|
+
export interface BinaryFormDataRequestField {
|
|
53
|
+
/**
|
|
54
|
+
* A binary field type discriminator.
|
|
55
|
+
*/
|
|
56
|
+
type: 'binary';
|
|
57
|
+
/**
|
|
58
|
+
* The name of the field.
|
|
59
|
+
*/
|
|
60
|
+
name: string;
|
|
61
|
+
/**
|
|
62
|
+
* The content type of the data contained in `value`.
|
|
63
|
+
* The default content type for the binary is 'application/octet-stream'.
|
|
64
|
+
*/
|
|
65
|
+
contentType?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The filename reported to the server.
|
|
68
|
+
* The default filename for the binary is 'binary'.
|
|
69
|
+
*/
|
|
70
|
+
filename?: string;
|
|
71
|
+
/**
|
|
72
|
+
* The field's value.
|
|
73
|
+
*/
|
|
74
|
+
value: ArrayBuffer | Blob | ReadableStream | Buffer | stream.Readable | Binary | File;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Represents a multipart/form-data field.
|
|
78
|
+
*/
|
|
79
|
+
export declare type FormDataRequestField = TextFormDataRequestField | JsonFormDataRequestField | BinaryFormDataRequestField;
|
|
80
|
+
/**
|
|
81
|
+
* Represents a multipart/form-data body.
|
|
82
|
+
*/
|
|
83
|
+
export declare type FormDataRequestBody = Array<FormDataRequestField>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Binary } from './binary';
|
|
2
|
+
export interface TextFormDataResponseField {
|
|
3
|
+
type: 'text';
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface BinaryFormDataResponseField {
|
|
8
|
+
type: 'binary';
|
|
9
|
+
name: string;
|
|
10
|
+
contentType: string;
|
|
11
|
+
filename: string;
|
|
12
|
+
value: Binary;
|
|
13
|
+
}
|
|
14
|
+
export declare type FormDataResponseField = TextFormDataResponseField | BinaryFormDataResponseField;
|
|
15
|
+
export declare type FormDataResponseBody = Array<FormDataResponseField>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseError } from './base-error';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a situation when the request was aborted.
|
|
4
|
+
*/
|
|
5
|
+
export interface HttpClientAbortError extends BaseError {
|
|
6
|
+
/**
|
|
7
|
+
* The error name.
|
|
8
|
+
*/
|
|
9
|
+
readonly name: 'AbortError';
|
|
10
|
+
/**
|
|
11
|
+
* The error root cause.
|
|
12
|
+
*/
|
|
13
|
+
readonly cause?: any;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseError } from './base-error';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a situation when a network error occurred.
|
|
4
|
+
*/
|
|
5
|
+
export interface HttpClientNetworkError extends BaseError {
|
|
6
|
+
/**
|
|
7
|
+
* The error name.
|
|
8
|
+
*/
|
|
9
|
+
readonly name: 'NetworkError';
|
|
10
|
+
/**
|
|
11
|
+
* The error root cause.
|
|
12
|
+
*/
|
|
13
|
+
readonly cause?: any;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseError } from './base-error';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a situation when the request is invalid and cannot be sent.
|
|
4
|
+
*/
|
|
5
|
+
export interface HttpClientRequestError extends BaseError {
|
|
6
|
+
/**
|
|
7
|
+
* The error name.
|
|
8
|
+
*/
|
|
9
|
+
readonly name: 'RequestError';
|
|
10
|
+
/**
|
|
11
|
+
* The error root cause.
|
|
12
|
+
*/
|
|
13
|
+
readonly cause?: any;
|
|
14
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RequestBodyTypes } from './request-body-types';
|
|
2
|
+
import { Headers } from './headers';
|
|
3
|
+
import { AbortSignal } from './abort-signal';
|
|
4
|
+
import { StatusValidator } from './status-validator';
|
|
5
|
+
/**
|
|
6
|
+
* Represents the options used to configure the request.
|
|
7
|
+
*/
|
|
8
|
+
export interface HttpClientRequestOptions<T extends keyof RequestBodyTypes = 'json'> {
|
|
9
|
+
/**
|
|
10
|
+
* The URL of the resource to fetch.
|
|
11
|
+
*/
|
|
12
|
+
url: string;
|
|
13
|
+
/**
|
|
14
|
+
* The request method, e.g. `GET`, `POST`.
|
|
15
|
+
*/
|
|
16
|
+
method?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The request headers.
|
|
19
|
+
*/
|
|
20
|
+
headers?: Headers;
|
|
21
|
+
/**
|
|
22
|
+
* A request body that will be send along with the request.
|
|
23
|
+
* The structure of the request body needs to conform to the specified request body type.
|
|
24
|
+
*/
|
|
25
|
+
body?: RequestBodyTypes[T];
|
|
26
|
+
/**
|
|
27
|
+
* The type of the request body. Can be `text`, `json`, `binary` or `form-data`.
|
|
28
|
+
* The default request body type is `json`.
|
|
29
|
+
*/
|
|
30
|
+
requestBodyType?: T;
|
|
31
|
+
/**
|
|
32
|
+
* An AbortSignal instance that can be used to cancel the request.
|
|
33
|
+
*/
|
|
34
|
+
abortSignal?: AbortSignal;
|
|
35
|
+
/**
|
|
36
|
+
* A custom status validator function.
|
|
37
|
+
* If the status validator function returns `true` the returned promise resolves with the `HttpClientResponse`
|
|
38
|
+
* Otherwise the promise rejects with the `StatusError`.
|
|
39
|
+
* The default status validator function considers the `2xx` status codes as valid.
|
|
40
|
+
*/
|
|
41
|
+
statusValidator?: StatusValidator;
|
|
42
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpClientResponse } from './http-client-response';
|
|
2
|
+
import { BaseError } from './base-error';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a situation when the response status is considered invalid by the status validator.
|
|
5
|
+
*/
|
|
6
|
+
export interface HttpClientResponseError extends BaseError {
|
|
7
|
+
/**
|
|
8
|
+
* The error name.
|
|
9
|
+
*/
|
|
10
|
+
readonly name: 'ResponseError';
|
|
11
|
+
/**
|
|
12
|
+
* The error root cause.
|
|
13
|
+
*/
|
|
14
|
+
readonly cause?: any;
|
|
15
|
+
/**
|
|
16
|
+
* The response.
|
|
17
|
+
*/
|
|
18
|
+
readonly response: HttpClientResponse;
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ResponseBodyTypes } from './response-body-types';
|
|
2
|
+
import { Headers } from './headers';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the response to a request.
|
|
5
|
+
*/
|
|
6
|
+
export interface HttpClientResponse {
|
|
7
|
+
/**
|
|
8
|
+
* The URL of the response.
|
|
9
|
+
*/
|
|
10
|
+
readonly url: string;
|
|
11
|
+
/**
|
|
12
|
+
* The status code of the response.
|
|
13
|
+
*/
|
|
14
|
+
readonly status: number;
|
|
15
|
+
/**
|
|
16
|
+
* The status message corresponding to the status code.
|
|
17
|
+
*/
|
|
18
|
+
readonly statusText: string;
|
|
19
|
+
/**
|
|
20
|
+
* The response headers.
|
|
21
|
+
*/
|
|
22
|
+
readonly headers: Headers;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the response body in a form that conforms to the specified response body type.
|
|
25
|
+
*
|
|
26
|
+
* @param responseBodyType The type of the response body.
|
|
27
|
+
* Can be `text`, `json`, `binary`, `form-data`, `array-buffer`, `blob`, `readable-stream`, `buffer` or `stream`.
|
|
28
|
+
* The default response body type is `json`.
|
|
29
|
+
* @throws DataTypeError when the response body does not conform to the specified response body type.
|
|
30
|
+
* @throws UnsupportedOperationError when the response body type is not supported by the platform.
|
|
31
|
+
*/
|
|
32
|
+
body<T extends keyof ResponseBodyTypes = 'json'>(responseBodyType?: T): ResponseBodyTypes[T];
|
|
33
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RequestBodyTypes } from './request-body-types';
|
|
2
|
+
import { HttpClientRequestOptions } from './http-client-request-options';
|
|
3
|
+
import { HttpClientResponse } from './http-client-response';
|
|
4
|
+
/**
|
|
5
|
+
* The http client that serves as an environment agnostic (browser vs node) abstraction for making http calls.
|
|
6
|
+
* It handles the authentication of the requests made to the Platform Services and the Serverless Functions.
|
|
7
|
+
*
|
|
8
|
+
* Currently, only the requests to the Platform Services and the Serverless Functions are supported.
|
|
9
|
+
*/
|
|
10
|
+
export interface HttpClient {
|
|
11
|
+
/**
|
|
12
|
+
* Sends an http request as configured by the `options`.
|
|
13
|
+
* Returns a promise that resolves with a response object for successful requests or rejects with an appropriate error
|
|
14
|
+
* when one of the following situations happen:
|
|
15
|
+
* - `DataTypeError` - request body does not conform to the specified request body type,
|
|
16
|
+
* - `HttpClientRequestError` - request cannot be sent (e.g. due to network error or invalid request),
|
|
17
|
+
* - `HttpClientResponseError` - response status is considered invalid by the status validator,
|
|
18
|
+
* - `HttpClientAbortError` - request was aborted.
|
|
19
|
+
*
|
|
20
|
+
* @param options Options used to configure the request.
|
|
21
|
+
* @return Promise<HttpClientResponse> A promise that resolves with the response object or rejects with an error.
|
|
22
|
+
*/
|
|
23
|
+
send<T extends keyof RequestBodyTypes = 'json'>(options: HttpClientRequestOptions<T>): Promise<HttpClientResponse>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './base-error';
|
|
2
|
+
export * from './http-client-request-error';
|
|
3
|
+
export * from './unsupported-operation-error';
|
|
4
|
+
export * from './status-validator';
|
|
5
|
+
export * from './response-body-types';
|
|
6
|
+
export * from './http-client';
|
|
7
|
+
export * from './http-client-response';
|
|
8
|
+
export * from './data-types';
|
|
9
|
+
export * from './http-client-request-options';
|
|
10
|
+
export * from './http-client-abort-error';
|
|
11
|
+
export * from './abort-controller';
|
|
12
|
+
export * from './form-data-response-body';
|
|
13
|
+
export * from './abort-signal';
|
|
14
|
+
export * from './http-client-response-error';
|
|
15
|
+
export * from './form-data-request-body';
|
|
16
|
+
export * from './binary';
|
|
17
|
+
export * from './headers';
|
|
18
|
+
export * from './request-body-types';
|
|
19
|
+
export * from './data-type-error';
|
|
20
|
+
export * from './http-client-network-error';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { FormDataRequestBody } from './form-data-request-body';
|
|
4
|
+
import type * as stream from 'stream';
|
|
5
|
+
import { Binary } from './binary';
|
|
6
|
+
/**
|
|
7
|
+
* Mapping between the request body type names and types.
|
|
8
|
+
*/
|
|
9
|
+
export declare type RequestBodyTypes = {
|
|
10
|
+
/**
|
|
11
|
+
* A text request body type.
|
|
12
|
+
*/
|
|
13
|
+
text: string;
|
|
14
|
+
/**
|
|
15
|
+
* A JSON request body type.
|
|
16
|
+
*/
|
|
17
|
+
json: any;
|
|
18
|
+
/**
|
|
19
|
+
* A multipart/form-data request body type.
|
|
20
|
+
*/
|
|
21
|
+
'form-data': FormDataRequestBody;
|
|
22
|
+
/**
|
|
23
|
+
* A binary request body type.
|
|
24
|
+
*/
|
|
25
|
+
binary: Binary | ArrayBuffer | Blob | ReadableStream | Buffer | stream.Readable;
|
|
26
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type * as stream from 'stream';
|
|
4
|
+
import { FormDataResponseBody } from './form-data-response-body';
|
|
5
|
+
import { Binary } from './binary';
|
|
6
|
+
/**
|
|
7
|
+
* Mapping between the response body type names and types.
|
|
8
|
+
*/
|
|
9
|
+
export declare type ResponseBodyTypes = {
|
|
10
|
+
/**
|
|
11
|
+
* A text response body type.
|
|
12
|
+
*/
|
|
13
|
+
text: Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* A JSON response body type.
|
|
16
|
+
*/
|
|
17
|
+
json: Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* A binary body type.
|
|
20
|
+
*/
|
|
21
|
+
binary: Promise<Binary>;
|
|
22
|
+
/**
|
|
23
|
+
* A multipart/form-data body type.
|
|
24
|
+
*/
|
|
25
|
+
'form-data': Promise<FormDataResponseBody>;
|
|
26
|
+
/**
|
|
27
|
+
* An ArrayBuffer response body type.
|
|
28
|
+
*/
|
|
29
|
+
'array-buffer': Promise<ArrayBuffer>;
|
|
30
|
+
/**
|
|
31
|
+
* A Blob response body type. Browser only.
|
|
32
|
+
*/
|
|
33
|
+
blob: Promise<Blob>;
|
|
34
|
+
/**
|
|
35
|
+
* A ReadableStream response body type. Browser only.
|
|
36
|
+
*/
|
|
37
|
+
'readable-stream': ReadableStream<Uint8Array>;
|
|
38
|
+
/**
|
|
39
|
+
* A Buffer response body type. Node only.
|
|
40
|
+
*/
|
|
41
|
+
buffer: Promise<Buffer>;
|
|
42
|
+
/**
|
|
43
|
+
* A Stream response body type. Node only.
|
|
44
|
+
*/
|
|
45
|
+
stream: stream.Readable;
|
|
46
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a function used to validate the response status code.
|
|
3
|
+
* If `true` is returned, the status is considered valid (request succeeded), otherwise it's considered invalid (request failed).
|
|
4
|
+
*/
|
|
5
|
+
export interface StatusValidator {
|
|
6
|
+
(status: number): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a situation when the requested operation is not supported.
|
|
3
|
+
*/
|
|
4
|
+
import { BaseError } from './base-error';
|
|
5
|
+
export interface UnsupportedOperationError extends BaseError {
|
|
6
|
+
/**
|
|
7
|
+
* The error name.
|
|
8
|
+
*/
|
|
9
|
+
readonly name: 'UnsupportedOperationError';
|
|
10
|
+
/**
|
|
11
|
+
* The error root cause.
|
|
12
|
+
*/
|
|
13
|
+
readonly cause?: any;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GlobalErrorSerializer } from './types/global-error-serializer';
|
|
2
|
+
/**
|
|
3
|
+
* Registers a global error serializer for handling uncatched errors.
|
|
4
|
+
*
|
|
5
|
+
* @param {GlobalErrorSerializer} serializer Asynchronous function which serializes error if it match the condition
|
|
6
|
+
*/
|
|
7
|
+
export declare function addGlobalErrorSerializer(serializer: GlobalErrorSerializer): void;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if global error serializer is supported.
|
|
10
|
+
*
|
|
11
|
+
* @return {boolean} information if global error serializer is supported on current environment.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isGlobalErrorSerializerSupported(): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SerializedError } from './serialized-error';
|
|
2
|
+
/**
|
|
3
|
+
* Custom error serializing function.
|
|
4
|
+
* Should check the received error and, when the error matches, return a serialized error with the specified error type.
|
|
5
|
+
* Otherwise, nothing should be returned so that the error can be handled further.
|
|
6
|
+
*
|
|
7
|
+
* @param {any} error Error to be serialized
|
|
8
|
+
* @returns {TypedError | undefined} Serialized error or nothing
|
|
9
|
+
*/
|
|
10
|
+
export declare type GlobalErrorSerializer = (error: any) => Promise<SerializedError | undefined>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommonSerializedError } from './common-serialized-error';
|
|
2
|
+
import { HttpSerializedError } from './http-serialized-error';
|
|
3
|
+
/**
|
|
4
|
+
* Serialized error object contains error type
|
|
5
|
+
*
|
|
6
|
+
* @property {ErrorType} type error type
|
|
7
|
+
*/
|
|
8
|
+
export declare type SerializedError = HttpSerializedError | CommonSerializedError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils/get-global-with-dt-runtime';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getGlobalWithDtRuntime: <T extends typeof globalThis>() => T;
|