@dynatrace-sdk/http-client 1.5.1 → 1.6.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/types/index.d.ts CHANGED
@@ -1,617 +1,934 @@
1
- /// <reference types="node" />
2
-
3
- import type * as stream from 'stream';
4
-
5
- /**
6
- * Represents a controller object that allows to abort one or more requests as and when desired.
7
- */
8
- declare interface AbortController_2 {
9
- /**
10
- * Aborts a request before it has completed.
11
- */
12
- abort(): void;
13
- /**
14
- * Returns an AbortSignal object instance, which can be used to communicate with a request.
15
- */
16
- signal: AbortSignal_2;
17
- }
18
- export { AbortController_2 as AbortController }
19
-
20
- declare type AbortSignal_2 = HttpClientAbortSignal | globalThis.AbortSignal;
21
- export { AbortSignal_2 as AbortSignal }
22
-
23
- export declare interface BaseError extends Error {
24
- readonly name: string;
25
- readonly cause?: any;
26
- }
27
-
28
- /**
29
- * Represents an environment agnostic (browser vs node) abstraction layer for binary data.
30
- */
31
- export declare interface Binary {
32
- /**
33
- * Returns the binary data in a form that conforms to the specified type.
34
- *
35
- * @param type The type of the data.
36
- * Can be `text`, `json`, `array-buffer`, `blob`, `readable-stream`, `buffer` or `stream`.
37
- * @throws {DataTypeError} Data does not conform to the specified type.
38
- * @throws {UnsupportedOperationError} Type is not supported by the platform.
39
- */
40
- get<T extends keyof DataTypes>(type: T): DataTypes[T];
41
- }
42
-
43
- /**
44
- * Represents an binary field.
45
- */
46
- export declare interface BinaryFormDataRequestField {
47
- /**
48
- * A binary field type discriminator.
49
- */
50
- type: 'binary';
51
- /**
52
- * The name of the field.
53
- */
54
- name: string;
55
- /**
56
- * The content type of the data contained in `value`.
57
- * The default content type for the binary is 'application/octet-stream'.
58
- */
59
- contentType?: string;
60
- /**
61
- * The filename reported to the server.
62
- * The default filename for the binary is 'binary'.
63
- */
64
- filename?: string;
65
- /**
66
- * The field's value.
67
- */
68
- value: ArrayBuffer | Blob | ReadableStream | Buffer | stream.Readable | Binary | File;
69
- }
70
-
71
- export declare interface BinaryFormDataResponseField {
72
- type: 'binary';
73
- name: string;
74
- contentType: string;
75
- filename: string;
76
- value: Binary;
77
- }
78
-
79
- export declare interface DataTypeError extends BaseError {
80
- /**
81
- * The error name.
82
- */
83
- readonly name: 'DataTypeError';
84
- /**
85
- * The error root cause.
86
- */
87
- readonly cause?: any;
88
- }
89
-
90
- /**
91
- * Mapping between the data type names and types.
92
- */
93
- export declare type DataTypes = {
94
- /**
95
- * A text type.
96
- */
97
- text: Promise<string>;
98
- /**
99
- * A JSON type.
100
- */
101
- json: Promise<any>;
102
- /**
103
- * An ArrayBuffer type.
104
- */
105
- 'array-buffer': Promise<ArrayBuffer>;
106
- /**
107
- * A Blob type. Browser only.
108
- */
109
- blob: Promise<Blob>;
110
- /**
111
- * A ReadableStream type. Browser only.
112
- */
113
- 'readable-stream': ReadableStream<Uint8Array>;
114
- /**
115
- * A Buffer type. Node only.
116
- */
117
- buffer: Promise<Buffer>;
118
- /**
119
- * A Stream type. Node only.
120
- */
121
- stream: stream.Readable;
122
- };
123
-
124
- /**
125
- * Represents a multipart/form-data body.
126
- */
127
- export declare type FormDataRequestBody = Array<FormDataRequestField>;
128
-
129
- /**
130
- * Represents a multipart/form-data field.
131
- */
132
- export declare type FormDataRequestField = TextFormDataRequestField | JsonFormDataRequestField | BinaryFormDataRequestField;
133
-
134
- export declare type FormDataResponseBody = Array<FormDataResponseField>;
135
-
136
- export declare type FormDataResponseField = TextFormDataResponseField | BinaryFormDataResponseField;
137
-
138
- /**
139
- * Represents http headers.
140
- */
141
- declare interface Headers_2 {
142
- [key: string]: string;
143
- }
144
- export { Headers_2 as Headers }
145
-
146
- /**
147
- * The http client that serves as an environment agnostic (browser vs node) abstraction for making http calls.
148
- * It handles the authentication of the requests made to the Platform Services and the Serverless Functions.
149
- *
150
- * Currently, only the requests to the Platform Services and the Serverless Functions are supported.
151
- */
152
- export declare interface HttpClient {
153
- /**
154
- * Sends an http request as configured by the `options`.
155
- * Returns a promise that resolves with a response object for successful requests or rejects with an appropriate error
156
- * when one of the following situations happen:
157
- * - `DataTypeError` - request body does not conform to the specified request body type,
158
- * - `HttpClientRequestError` - request cannot be sent (e.g. due to network error or invalid request),
159
- * - `HttpClientResponseError` - response status is considered invalid by the status validator,
160
- * - `HttpClientAbortError` - request was aborted.
161
- *
162
- * @param options Options used to configure the request.
163
- * @return Promise<HttpClientResponse> A promise that resolves with the response object or rejects with an error.
164
- */
165
- send<T extends keyof RequestBodyTypes = 'json'>(options: HttpClientRequestOptions<T>): Promise<HttpClientResponse>;
166
- }
167
-
168
- export declare const httpClient: PlatformHttpClient;
169
-
170
- /**
171
- * Represents a situation when the request was aborted.
172
- */
173
- export declare interface HttpClientAbortError extends BaseError {
174
- /**
175
- * The error name.
176
- */
177
- readonly name: 'AbortError';
178
- /**
179
- * The error root cause.
180
- */
181
- readonly cause?: any;
182
- }
183
-
184
- /**
185
- * Represents a signal object that allows to communicate with the request and abort it using the `AbortController`.
186
- * @deprecated Will be removed from HttpClient. We encourage using native interface for AbortSignal.
187
- */
188
- declare interface HttpClientAbortSignal extends EventTarget {
189
- readonly reason: any;
190
- throwIfAborted(): void;
191
- /**
192
- * A flag indicating whether the requests the signal is communicating with are aborted.
193
- */
194
- readonly aborted: boolean;
195
- /**
196
- * Invoked when the requests the signal is communicating with are aborted.
197
- */
198
- onabort: ((this: AbortSignal_2, event: Event) => void) | null;
199
- }
200
-
201
- declare interface HttpClientConfiguration {
202
- baseUrl?: string;
203
- defaultHeaders?: Headers_2;
204
- }
205
-
206
- /**
207
- * Represents a situation when a network error occurred.
208
- */
209
- export declare interface HttpClientNetworkError extends BaseError {
210
- /**
211
- * The error name.
212
- */
213
- readonly name: 'NetworkError';
214
- /**
215
- * The error root cause.
216
- */
217
- readonly cause?: any;
218
- }
219
-
220
- /**
221
- * Represents a situation when the request is invalid and cannot be sent.
222
- */
223
- export declare interface HttpClientRequestError extends BaseError {
224
- /**
225
- * The error name.
226
- */
227
- readonly name: 'RequestError';
228
- /**
229
- * The error root cause.
230
- */
231
- readonly cause?: any;
232
- }
233
-
234
- /**
235
- * Represents the options used to configure the request.
236
- */
237
- export declare interface HttpClientRequestOptions<T extends keyof RequestBodyTypes = 'json'> {
238
- /**
239
- * The URL of the resource to fetch.
240
- */
241
- url: string;
242
- /**
243
- * The request method, e.g. `GET`, `POST`.
244
- */
245
- method?: string;
246
- /**
247
- * The request headers.
248
- */
249
- headers?: Headers_2;
250
- /**
251
- * A request body that will be send along with the request.
252
- * The structure of the request body needs to conform to the specified request body type.
253
- */
254
- body?: RequestBodyTypes[T];
255
- /**
256
- * The type of the request body. Can be `text`, `json`, `binary` or `form-data`.
257
- * The default request body type is `json`.
258
- */
259
- requestBodyType?: T;
260
- /**
261
- * An AbortSignal instance that can be used to cancel the request.
262
- */
263
- abortSignal?: AbortSignal_2;
264
- /**
265
- * A custom status validator function.
266
- * If the status validator function returns `true` the returned promise resolves with the `HttpClientResponse`
267
- * Otherwise the promise rejects with the `StatusError`.
268
- * The default status validator function considers the `2xx` status codes as valid.
269
- */
270
- statusValidator?: StatusValidator;
271
- }
272
-
273
- /**
274
- * Represents the response to a request.
275
- */
276
- export declare interface HttpClientResponse {
277
- /**
278
- * The URL of the response. May differ from `requestUrl` if the request was
279
- * redirected.
280
- */
281
- readonly url: string;
282
- /**
283
- * The URL that was originally requested, before any redirects were followed.
284
- */
285
- readonly requestUrl: string;
286
- /**
287
- * The status code of the response.
288
- */
289
- readonly status: number;
290
- /**
291
- * The status message corresponding to the status code.
292
- */
293
- readonly statusText: string;
294
- /**
295
- * The response headers.
296
- */
297
- readonly headers: Headers_2;
298
- /**
299
- * Returns the response body in a form that conforms to the specified response body type.
300
- *
301
- * @param responseBodyType The type of the response body.
302
- * Can be `text`, `json`, `binary`, `form-data`, `array-buffer`, `blob`, `readable-stream`, `buffer` or `stream`.
303
- * The default response body type is `json`.
304
- * @throws {DataTypeError} Response body does not conform to the specified response body type.
305
- * @throws {UnsupportedOperationError} Response body type is not supported by the platform.
306
- */
307
- body<T extends keyof ResponseBodyTypes = 'json'>(responseBodyType?: T): ResponseBodyTypes[T];
308
- }
309
-
310
- /**
311
- * Represents a situation when the response status is considered invalid by the status validator.
312
- */
313
- export declare interface HttpClientResponseError extends BaseError {
314
- /**
315
- * The error name.
316
- */
317
- readonly name: 'ResponseError';
318
- /**
319
- * The error root cause.
320
- */
321
- readonly cause?: any;
322
- /**
323
- * The response.
324
- */
325
- readonly response: HttpClientResponse;
326
- }
327
-
328
- export declare function isHttpClientAbortError(e: any): e is HttpClientAbortError;
329
-
330
- export declare function isHttpClientNetworkError(e: any): e is HttpClientNetworkError;
331
-
332
- export declare function isHttpClientRequestError(e: any): e is HttpClientRequestError;
333
-
334
- export declare function isHttpClientResponseError(e: any): e is HttpClientResponseError;
335
-
336
- /**
337
- * Represents a JSON field.
338
- */
339
- export declare interface JsonFormDataRequestField {
340
- /**
341
- * A JSON field type discriminator.
342
- */
343
- type: 'json';
344
- /**
345
- * The name of the field.
346
- */
347
- name: string;
348
- /**
349
- * The content type of the data contained in `value`.
350
- * The default content type for the JSON is 'application/json'.
351
- */
352
- contentType?: string;
353
- /**
354
- * The filename reported to the server.
355
- * The default filename for the JSON is 'json'.
356
- */
357
- filename?: string;
358
- /**
359
- * The field's value.
360
- */
361
- value: any;
362
- }
363
-
364
- /**
365
- * DO NOT USE - internal use only.
366
- */
367
- export declare class _OAuthHttpClient implements types.HttpClient {
368
- private readonly config;
369
- private oauthToken?;
370
- constructor(config: _OAuthHttpClientConfig);
371
- send<T extends keyof types.RequestBodyTypes = 'json'>(options: types.HttpClientRequestOptions<T>): Promise<types.HttpClientResponse>;
372
- private requestToken;
373
- }
374
-
375
- /**
376
- * DO NOT USE - internal use only.
377
- */
378
- export declare interface _OAuthHttpClientConfig {
379
- clientId: string;
380
- secret: string;
381
- scopes: string[];
382
- environmentUrl: string;
383
- authUrl: string;
384
- }
385
-
386
- export declare const PlatformAbortController: {
387
- new (): types.AbortController;
388
- };
389
-
390
- export declare type PlatformAbortController = InstanceType<typeof PlatformAbortController>;
391
-
392
- export declare const PlatformAbortSignal: {
393
- new (): types.AbortSignal;
394
- };
395
-
396
- export declare type PlatformAbortSignal = InstanceType<typeof PlatformAbortSignal>;
397
-
398
- export declare abstract class PlatformBaseError extends Error implements types.BaseError {
399
- readonly cause?: any;
400
- protected constructor(message: string, cause?: any);
401
- }
402
-
403
- export declare class PlatformBinary implements types.Binary {
404
- readonly data: Blob | ArrayBuffer | ReadableStream<Uint8Array>;
405
- static fromText(text: string): PlatformBinary;
406
- static fromJson(json: any): PlatformBinary;
407
- static from(data: Blob | ArrayBuffer | ReadableStream<Uint8Array> | Buffer | stream.Readable): PlatformBinary;
408
- private constructor();
409
- get<T extends keyof types.DataTypes>(type: T): types.DataTypes[T];
410
- }
411
-
412
- export declare class PlatformDataTypeError extends PlatformBaseError implements types.DataTypeError {
413
- readonly name = "DataTypeError";
414
- constructor(message: string, cause?: any);
415
- }
416
-
417
- export declare class PlatformHttpClient implements types.HttpClient {
418
- private _baseUrl;
419
- private _defaultHeaders;
420
- constructor(options?: HttpClientConfiguration);
421
- /**
422
- * Sets HTTP Client Instance baseUrl param to the incoming value `baseUrl`.
423
- * @param baseUrl Base URL used in the request path.
424
- */
425
- _setBaseURL(baseUrl: string): void;
426
- /**
427
- * Sets HTTP Client Instance defaultHeaders param to the incoming value `defaultHeaders`.
428
- * @param defaultHeaders HTTP Headers to be used in outgoing requests.
429
- */
430
- _setDefaultHeaders(defaultHeaders: Headers_2): void;
431
- send<T extends keyof types.RequestBodyTypes = 'json'>(options: types.HttpClientRequestOptions<T>): Promise<types.HttpClientResponse>;
432
- }
433
-
434
- export declare class PlatformHttpClientAbortError extends Error implements types.HttpClientAbortError {
435
- readonly cause: any;
436
- readonly name = "AbortError";
437
- constructor(cause: any);
438
- }
439
-
440
- export declare class PlatformHttpClientRequestError extends PlatformBaseError implements types.HttpClientRequestError {
441
- readonly cause: any;
442
- readonly name = "RequestError";
443
- constructor(cause: any);
444
- }
445
-
446
- export declare class PlatformHttpClientResponse implements types.HttpClientResponse {
447
- private response;
448
- readonly requestUrl: string;
449
- constructor(response: Response, data?: {
450
- requestUrl: string;
451
- });
452
- get url(): string;
453
- get status(): number;
454
- get statusText(): string;
455
- get headers(): types.Headers;
456
- body<T extends keyof types.ResponseBodyTypes = 'json'>(responseBodyType?: T): types.ResponseBodyTypes[T];
457
- }
458
-
459
- export declare class PlatformHttpClientResponseError extends PlatformBaseError implements types.HttpClientResponseError {
460
- readonly name = "ResponseError";
461
- readonly response: PlatformHttpClientResponse;
462
- readonly requestMethod?: string;
463
- constructor(response: Response, data?: {
464
- requestUrl?: string;
465
- requestMethod?: string;
466
- });
467
- }
468
-
469
- export declare class PlatformUnsupportedOperationError extends PlatformBaseError implements types.UnsupportedOperationError {
470
- readonly name = "UnsupportedOperationError";
471
- constructor(message: string, cause?: any);
472
- }
473
-
474
- /**
475
- * Mapping between the request body type names and types.
476
- */
477
- export declare type RequestBodyTypes = {
478
- /**
479
- * A text request body type.
480
- */
481
- text: string;
482
- /**
483
- * A JSON request body type.
484
- */
485
- json: any;
486
- /**
487
- * A multipart/form-data request body type.
488
- */
489
- 'form-data': FormDataRequestBody;
490
- /**
491
- * A binary request body type.
492
- */
493
- binary: Binary | ArrayBuffer | Blob | ReadableStream | Buffer | stream.Readable;
494
- };
495
-
496
- /**
497
- * Mapping between the response body type names and types.
498
- */
499
- export declare type ResponseBodyTypes = {
500
- /**
501
- * A text response body type.
502
- */
503
- text: Promise<string>;
504
- /**
505
- * A JSON response body type.
506
- */
507
- json: Promise<any>;
508
- /**
509
- * A binary body type.
510
- */
511
- binary: Promise<Binary>;
512
- /**
513
- * A multipart/form-data body type.
514
- */
515
- 'form-data': Promise<FormDataResponseBody>;
516
- /**
517
- * An ArrayBuffer response body type.
518
- */
519
- 'array-buffer': Promise<ArrayBuffer>;
520
- /**
521
- * A Blob response body type. Browser only.
522
- */
523
- blob: Promise<Blob>;
524
- /**
525
- * A ReadableStream response body type. Browser only.
526
- */
527
- 'readable-stream': ReadableStream<Uint8Array>;
528
- /**
529
- * A Buffer response body type. Node only.
530
- */
531
- buffer: Promise<Buffer>;
532
- /**
533
- * A Stream response body type. Node only.
534
- */
535
- stream: stream.Readable;
536
- };
537
-
538
- /**
539
- * Represents a function used to validate the response status code.
540
- * If `true` is returned, the status is considered valid (request succeeded), otherwise it's considered invalid (request failed).
541
- */
542
- export declare interface StatusValidator {
543
- (status: number): boolean;
544
- }
545
-
546
- /**
547
- * Represents a plain text field. No filename and content type is set.
548
- */
549
- export declare interface TextFormDataRequestField {
550
- /**
551
- * A plain text field type discriminator.
552
- */
553
- type: 'text';
554
- /**
555
- * The name of the field.
556
- */
557
- name: string;
558
- /**
559
- * The field's value.
560
- */
561
- value: string;
562
- }
563
-
564
- export declare interface TextFormDataResponseField {
565
- type: 'text';
566
- name: string;
567
- value: string;
568
- }
569
-
570
- declare namespace types {
571
- export {
572
- BaseError,
573
- isHttpClientRequestError,
574
- HttpClientRequestError,
575
- UnsupportedOperationError,
576
- StatusValidator,
577
- ResponseBodyTypes,
578
- HttpClient,
579
- HttpClientResponse,
580
- DataTypes,
581
- HttpClientRequestOptions,
582
- isHttpClientAbortError,
583
- HttpClientAbortError,
584
- AbortController_2 as AbortController,
585
- TextFormDataResponseField,
586
- BinaryFormDataResponseField,
587
- FormDataResponseField,
588
- FormDataResponseBody,
589
- AbortSignal_2 as AbortSignal,
590
- isHttpClientResponseError,
591
- HttpClientResponseError,
592
- TextFormDataRequestField,
593
- JsonFormDataRequestField,
594
- BinaryFormDataRequestField,
595
- FormDataRequestField,
596
- FormDataRequestBody,
597
- Binary,
598
- Headers_2 as Headers,
599
- RequestBodyTypes,
600
- DataTypeError,
601
- isHttpClientNetworkError,
602
- HttpClientNetworkError
603
- }
604
- }
605
-
606
- export declare interface UnsupportedOperationError extends BaseError {
607
- /**
608
- * The error name.
609
- */
610
- readonly name: 'UnsupportedOperationError';
611
- /**
612
- * The error root cause.
613
- */
614
- readonly cause?: any;
615
- }
616
-
617
- export { }
1
+ /// <reference types="node" />
2
+
3
+ import type * as stream from 'stream';
4
+
5
+ /**
6
+ * Represents a controller object that allows to abort one or more requests as and when desired.
7
+ */
8
+ declare interface AbortController_2 {
9
+ /**
10
+ * Aborts a request before it has completed.
11
+ */
12
+ abort(): void;
13
+ /**
14
+ * Returns an AbortSignal object instance, which can be used to communicate with a request.
15
+ */
16
+ signal: AbortSignal_2;
17
+ }
18
+ export { AbortController_2 as AbortController }
19
+
20
+ declare type AbortSignal_2 = HttpClientAbortSignal | globalThis.AbortSignal;
21
+ export { AbortSignal_2 as AbortSignal }
22
+
23
+ /**
24
+ * Base error for all client SDKs. All other errors extend this class.
25
+ */
26
+ export declare class _ApiClientError extends Error {
27
+ readonly cause?: any;
28
+ readonly isApiClientError = true;
29
+ errorType: _ErrorType;
30
+ constructor(name: string, message?: string, cause?: any);
31
+ }
32
+
33
+ /**
34
+ * Dedicated error response class for errors thrown by API Gateway.
35
+ * Autogenerated SDK Clients have built-in handler for API Gateway errors that throws this error.
36
+ */
37
+ export declare class _ApiGatewayError extends _ClientRequestError<_ApiGatewayErrorResponseBody> {
38
+ readonly isApiGatewayError = true;
39
+ readonly code: number;
40
+ readonly retryAfterSeconds: number | undefined;
41
+ constructor(response: HttpClientResponse, body: _ApiGatewayErrorResponseBody);
42
+ }
43
+
44
+ /**
45
+ * Reference for *ApiGatewayError* details object. Contains information about received API Getaway error.
46
+ * */
47
+ export declare interface _ApiGatewayErrorDetails extends _CommonErrorDetails {
48
+ errorCodeProperties?: {
49
+ [key: string]: string;
50
+ };
51
+ }
52
+
53
+ export declare type _ApiGatewayErrorResponseBody = _ErrorResponseBody<_CommonApiError<_ApiGatewayErrorDetails> & {
54
+ retryAfterSeconds?: number;
55
+ }>;
56
+
57
+ export declare interface BaseError extends Error {
58
+ readonly name: string;
59
+ readonly cause?: any;
60
+ }
61
+
62
+ /**
63
+ * Represents an environment agnostic (browser vs node) abstraction layer for binary data.
64
+ */
65
+ export declare interface Binary {
66
+ /**
67
+ * Returns the binary data in a form that conforms to the specified type.
68
+ *
69
+ * @param type The type of the data.
70
+ * Can be `text`, `json`, `array-buffer`, `blob`, `readable-stream`, `buffer` or `stream`.
71
+ * @throws {DataTypeError} Data does not conform to the specified type.
72
+ * @throws {UnsupportedOperationError} Type is not supported by the platform.
73
+ */
74
+ get<T extends keyof DataTypes>(type: T): DataTypes[T];
75
+ }
76
+
77
+ /**
78
+ * Represents an binary field.
79
+ */
80
+ export declare interface BinaryFormDataRequestField {
81
+ /**
82
+ * A binary field type discriminator.
83
+ */
84
+ type: 'binary';
85
+ /**
86
+ * The name of the field.
87
+ */
88
+ name: string;
89
+ /**
90
+ * The content type of the data contained in `value`.
91
+ * The default content type for the binary is 'application/octet-stream'.
92
+ */
93
+ contentType?: string;
94
+ /**
95
+ * The filename reported to the server.
96
+ * The default filename for the binary is 'binary'.
97
+ */
98
+ filename?: string;
99
+ /**
100
+ * The field's value.
101
+ */
102
+ value: ArrayBuffer | Blob | ReadableStream | Buffer | stream.Readable | Binary | File;
103
+ }
104
+
105
+ export declare interface BinaryFormDataResponseField {
106
+ type: 'binary';
107
+ name: string;
108
+ contentType: string;
109
+ filename: string;
110
+ value: Binary;
111
+ }
112
+
113
+ /**
114
+ * Generic error class for service errors, used to handle both expected and unexpected service-level errors.
115
+ * @example Handling unexpected error response, received by the SDK Client
116
+ * const responseValue = await response.body('json');
117
+ *
118
+ * throw new ClientRequestError(
119
+ * `${response.status}`,
120
+ * response,
121
+ * responseValue,
122
+ * getErrorMessage(
123
+ * responseValue,
124
+ * `Unexpected api response: code=${response.status} body="${responseValue}"`,
125
+ * ),
126
+ * e,
127
+ * );
128
+ *
129
+ */
130
+ export declare class _ClientRequestError<DTO = _ErrorResponseBody> extends _ApiClientError {
131
+ readonly isClientRequestError = true;
132
+ body: DTO;
133
+ response: HttpClientResponse;
134
+ constructor(name: string, response: HttpClientResponse, body: DTO, message?: string, cause?: any);
135
+ }
136
+
137
+ /**
138
+ * Common API error structure, established by Dynatrace API guidelines.
139
+ * */
140
+ export declare interface _CommonApiError<T extends _CommonErrorDetails & Record<string, any> = _CommonErrorDetails & Record<string, any>> {
141
+ /** The error code should be set to the HTTP error code by default.<br>
142
+ * The error code may be set to an API-specific error code which must be properly documented.*/
143
+ code: number;
144
+ /** The error message should be short and precise, it shouldn't contain details.*/
145
+ message: string;
146
+ /**
147
+ * An additional help field may be added which must be a URL to further information on how to deal with the error.<br>
148
+ * This may be some detailed error documentation page or a link to the Dynatrace support system, etc.
149
+ * */
150
+ help?: string;
151
+ /**
152
+ * Additional details about the error may be added in a details field.
153
+ * Refer to *CommonErrorDetails*
154
+ * */
155
+ details?: T;
156
+ }
157
+
158
+ /**
159
+ * *CommonApiError* details object reference. Contains common API error information.
160
+ * This object is used to convey additional information about the error like e.g., which query parameter exactly violated a precondition. <br>
161
+ * Details may contain any fields to further describe the error
162
+ * */
163
+ export declare interface _CommonErrorDetails {
164
+ /**
165
+ * UUID string that represents a reference of the error into e.g., the log file of the service.
166
+ * */
167
+ errorRef?: string;
168
+ /**
169
+ * String containing a 32-character hex integer value that's used for tracing.
170
+ * */
171
+ traceId?: string;
172
+ /**
173
+ * String value representing a more detailed error information than the http response code alone.
174
+ * Must be a single word in CamelCase, and all possible values must be documented.
175
+ * */
176
+ errorCode?: string;
177
+ /**
178
+ * An array of *ConstraintViolation* object, refer to ConstraintViolation object reference for more details.
179
+ * */
180
+ constraintViolations?: _ConstraintViolation[];
181
+ /**
182
+ * Must be an array of strings containing a complete list of missing IAM scopes necessary to successfully execute the request.
183
+ * Should be set if the API returns a 403 - Forbidden response in case of missing OAuth scopes.
184
+ * */
185
+ missingScopes?: string[];
186
+ /**
187
+ * Must be an array of strings containing a complete list of missing IAM permissions necessary to successfully execute the request.
188
+ * Should be set if the API returns a 403 - Forbidden response in case of missing OAuth user permissions.
189
+ * */
190
+ missingPermissions?: string[];
191
+ }
192
+
193
+ /**
194
+ * Contains information about an input parameter (path, query or request body)
195
+ * that violated some validation rule of the service API and caused the warning.<br>
196
+ * May contain additional fields further describing the warning.
197
+ * */
198
+ export declare interface _ConstraintViolation extends Record<string, string | undefined> {
199
+ /**
200
+ * Mandatory field message describing the warning.
201
+ * */
202
+ message: string;
203
+ /**
204
+ * Describes the general location of the violating parameter (query parameter, request body, etc.)
205
+ */
206
+ parameterLocation?: string;
207
+ /**
208
+ * Refers to the violating parameter within the parameterLocation.
209
+ */
210
+ path?: string;
211
+ }
212
+
213
+ export declare interface DataTypeError extends BaseError {
214
+ /**
215
+ * The error name.
216
+ */
217
+ readonly name: 'DataTypeError';
218
+ /**
219
+ * The error root cause.
220
+ */
221
+ readonly cause?: any;
222
+ }
223
+
224
+ /**
225
+ * Mapping between the data type names and types.
226
+ */
227
+ export declare type DataTypes = {
228
+ /**
229
+ * A text type.
230
+ */
231
+ text: Promise<string>;
232
+ /**
233
+ * A JSON type.
234
+ */
235
+ json: Promise<any>;
236
+ /**
237
+ * An ArrayBuffer type.
238
+ */
239
+ 'array-buffer': Promise<ArrayBuffer>;
240
+ /**
241
+ * A Blob type. Browser only.
242
+ */
243
+ blob: Promise<Blob>;
244
+ /**
245
+ * A ReadableStream type. Browser only.
246
+ */
247
+ 'readable-stream': ReadableStream<Uint8Array>;
248
+ /**
249
+ * A Buffer type. Node only.
250
+ */
251
+ buffer: Promise<Buffer>;
252
+ /**
253
+ * A Stream type. Node only.
254
+ */
255
+ stream: stream.Readable;
256
+ };
257
+
258
+ /**
259
+ * Basic error envelope, that enforces all error to have mandatory "error" property.
260
+ * */
261
+ export declare interface _ErrorResponseBody<T = _CommonApiError> {
262
+ /**
263
+ * *error* object must have two mandatory fields (*code, message*) and may have two additional fields (*help, details*):
264
+ * refer to the *CommonApiError* for more details.
265
+ * */
266
+ error: T;
267
+ }
268
+
269
+ /**
270
+ * Builds the typed error thrown for a response status, a status range or the `default` response.
271
+ */
272
+ export declare interface _ErrorResponseFactory {
273
+ /** Body type used to decode the error payload. Defaults to 'json'. */
274
+ responseBodyType?: _ResponseBodyTypeResolver;
275
+ /** Transform applied to the decoded error body before `build` is called. */
276
+ transformBody?: (body: unknown) => unknown;
277
+ /**
278
+ * Name of this response's error schema, reported as `expectedType` when its body can't be
279
+ * decoded or transformed. Falls back to `ExecuteRequestOptions.errorEnvelope`.
280
+ */
281
+ errorEnvelope?: string;
282
+ /** Constructs the final error thrown for this response. */
283
+ build: (ctx: {
284
+ response: HttpClientResponse;
285
+ body: unknown;
286
+ cause: unknown;
287
+ }) => Error;
288
+ }
289
+
290
+ /** @ignore*/
291
+ export declare enum _ErrorType {
292
+ COMMON = "JS Error",
293
+ HTTP = "Http Error"
294
+ }
295
+
296
+ /**
297
+ * Sends a request and dispatches the response the way generated SDK clients do:
298
+ * - The success body is decoded and optionally transformed.
299
+ * - Aborts, request-side `DataTypeError`s and `ClientRequestError`s are rethrown as-is; any other
300
+ * request failure is wrapped in `ApiClientError`.
301
+ * - API Gateway error responses throw `ApiGatewayError`.
302
+ * - Other error responses throw the error built by `errorFactories`, matched by exact status,
303
+ * then status range, then `default`. Without a match, the body is decoded as JSON and a
304
+ * generic `ClientRequestError` is thrown.
305
+ * - A body that can't be decoded or transformed throws `InvalidResponseError`, named
306
+ * `<operationId>:<status>` (`<operationId>:err` for the `default` response, `<status>` for the
307
+ * generic fallback).
308
+ *
309
+ * Unlike the inlined code it replaces, a body that fails to decode on the success, typed-error or
310
+ * API Gateway path throws `InvalidResponseError` (carrying the decode error as `nestedError` and
311
+ * the raw text body as `responseBody`) instead of the raw `DataTypeError`. `isInvalidResponseError`
312
+ * matches both.
313
+ */
314
+ export declare function _executeRequest<Req extends keyof RequestBodyTypes = 'json', TResponse = unknown>(options: _ExecuteRequestOptions<Req, TResponse>): Promise<TResponse>;
315
+
316
+ export declare interface _ExecuteRequestOptions<Req extends keyof RequestBodyTypes = 'json', TResponse = unknown> {
317
+ url: string;
318
+ method?: string;
319
+ headers?: Headers_2;
320
+ body?: RequestBodyTypes[Req];
321
+ requestBodyType?: Req;
322
+ abortSignal?: AbortSignal_2;
323
+ /** Defaults to the exported `httpClient` singleton. */
324
+ httpClient?: HttpClient;
325
+ /** Shorthand: builds a StatusValidator from a list. Mutually exclusive with `statusValidator`. */
326
+ acceptedStatusCodes?: ReadonlyArray<number>;
327
+ statusValidator?: StatusValidator;
328
+ /** Fixed body type, resolver callback, or 'none' to skip decoding. Defaults to 'json'. */
329
+ responseBodyType?: _ResponseBodyTypeResolver;
330
+ /** Post-decode transform on the success body. */
331
+ transformResponse?: (body: unknown, response: HttpClientResponse) => TResponse;
332
+ /** Identifies the calling operation in thrown errors, e.g. `MyServiceClient.myMethod`. */
333
+ operationId: string;
334
+ /** Default name of the expected error schema, for factories that don't set their own `errorEnvelope`. */
335
+ errorEnvelope?: string;
336
+ /**
337
+ * Error builders, looked up by exact status first, then by status range (for example `4XX`), then
338
+ * `default`. A status none of them match throws a generic `ClientRequestError`.
339
+ */
340
+ errorFactories?: {
341
+ [status: number]: _ErrorResponseFactory;
342
+ '1XX'?: _ErrorResponseFactory;
343
+ '2XX'?: _ErrorResponseFactory;
344
+ '3XX'?: _ErrorResponseFactory;
345
+ '4XX'?: _ErrorResponseFactory;
346
+ '5XX'?: _ErrorResponseFactory;
347
+ default?: _ErrorResponseFactory;
348
+ };
349
+ }
350
+
351
+ /**
352
+ * Represents a multipart/form-data body.
353
+ */
354
+ export declare type FormDataRequestBody = Array<FormDataRequestField>;
355
+
356
+ /**
357
+ * Represents a multipart/form-data field.
358
+ */
359
+ export declare type FormDataRequestField = TextFormDataRequestField | JsonFormDataRequestField | BinaryFormDataRequestField;
360
+
361
+ export declare type FormDataResponseBody = Array<FormDataResponseField>;
362
+
363
+ export declare type FormDataResponseField = TextFormDataResponseField | BinaryFormDataResponseField;
364
+
365
+ /**
366
+ * Represents http headers.
367
+ */
368
+ declare interface Headers_2 {
369
+ [key: string]: string;
370
+ }
371
+ export { Headers_2 as Headers }
372
+
373
+ /**
374
+ * The http client that serves as an environment agnostic (browser vs node) abstraction for making http calls.
375
+ * It handles the authentication of the requests made to the Platform Services and the Serverless Functions.
376
+ *
377
+ * Currently, only the requests to the Platform Services and the Serverless Functions are supported.
378
+ */
379
+ export declare interface HttpClient {
380
+ /**
381
+ * Sends an http request as configured by the `options`.
382
+ * Returns a promise that resolves with a response object for successful requests or rejects with an appropriate error
383
+ * when one of the following situations happen:
384
+ * - `DataTypeError` - request body does not conform to the specified request body type,
385
+ * - `HttpClientRequestError` - request cannot be sent (e.g. due to network error or invalid request),
386
+ * - `HttpClientResponseError` - response status is considered invalid by the status validator,
387
+ * - `HttpClientAbortError` - request was aborted.
388
+ *
389
+ * @param options Options used to configure the request.
390
+ * @return Promise<HttpClientResponse> A promise that resolves with the response object or rejects with an error.
391
+ */
392
+ send<T extends keyof RequestBodyTypes = 'json'>(options: HttpClientRequestOptions<T>): Promise<HttpClientResponse>;
393
+ }
394
+
395
+ export declare const httpClient: PlatformHttpClient;
396
+
397
+ /**
398
+ * Represents a situation when the request was aborted.
399
+ */
400
+ export declare interface HttpClientAbortError extends BaseError {
401
+ /**
402
+ * The error name.
403
+ */
404
+ readonly name: 'AbortError';
405
+ /**
406
+ * The error root cause.
407
+ */
408
+ readonly cause?: any;
409
+ }
410
+
411
+ /**
412
+ * Represents a signal object that allows to communicate with the request and abort it using the `AbortController`.
413
+ * @deprecated Will be removed from HttpClient. We encourage using native interface for AbortSignal.
414
+ */
415
+ declare interface HttpClientAbortSignal extends EventTarget {
416
+ readonly reason: any;
417
+ throwIfAborted(): void;
418
+ /**
419
+ * A flag indicating whether the requests the signal is communicating with are aborted.
420
+ */
421
+ readonly aborted: boolean;
422
+ /**
423
+ * Invoked when the requests the signal is communicating with are aborted.
424
+ */
425
+ onabort: ((this: AbortSignal_2, event: Event) => void) | null;
426
+ }
427
+
428
+ declare interface HttpClientConfiguration {
429
+ baseUrl?: string;
430
+ defaultHeaders?: Headers_2;
431
+ }
432
+
433
+ /**
434
+ * Represents a situation when a network error occurred.
435
+ */
436
+ export declare interface HttpClientNetworkError extends BaseError {
437
+ /**
438
+ * The error name.
439
+ */
440
+ readonly name: 'NetworkError';
441
+ /**
442
+ * The error root cause.
443
+ */
444
+ readonly cause?: any;
445
+ }
446
+
447
+ /**
448
+ * Represents a situation when the request is invalid and cannot be sent.
449
+ */
450
+ export declare interface HttpClientRequestError extends BaseError {
451
+ /**
452
+ * The error name.
453
+ */
454
+ readonly name: 'RequestError';
455
+ /**
456
+ * The error root cause.
457
+ */
458
+ readonly cause?: any;
459
+ }
460
+
461
+ /**
462
+ * Represents the options used to configure the request.
463
+ */
464
+ export declare interface HttpClientRequestOptions<T extends keyof RequestBodyTypes = 'json'> {
465
+ /**
466
+ * The URL of the resource to fetch.
467
+ */
468
+ url: string;
469
+ /**
470
+ * The request method, e.g. `GET`, `POST`.
471
+ */
472
+ method?: string;
473
+ /**
474
+ * The request headers.
475
+ */
476
+ headers?: Headers_2;
477
+ /**
478
+ * A request body that will be send along with the request.
479
+ * The structure of the request body needs to conform to the specified request body type.
480
+ */
481
+ body?: RequestBodyTypes[T];
482
+ /**
483
+ * The type of the request body. Can be `text`, `json`, `binary` or `form-data`.
484
+ * The default request body type is `json`.
485
+ */
486
+ requestBodyType?: T;
487
+ /**
488
+ * An AbortSignal instance that can be used to cancel the request.
489
+ */
490
+ abortSignal?: AbortSignal_2;
491
+ /**
492
+ * A custom status validator function.
493
+ * If the status validator function returns `true` the returned promise resolves with the `HttpClientResponse`
494
+ * Otherwise the promise rejects with the `StatusError`.
495
+ * The default status validator function considers the `2xx` status codes as valid.
496
+ */
497
+ statusValidator?: StatusValidator;
498
+ }
499
+
500
+ /**
501
+ * Represents the response to a request.
502
+ */
503
+ export declare interface HttpClientResponse {
504
+ /**
505
+ * The URL of the response. May differ from `requestUrl` if the request was
506
+ * redirected.
507
+ */
508
+ readonly url: string;
509
+ /**
510
+ * The URL that was originally requested, before any redirects were followed.
511
+ */
512
+ readonly requestUrl: string;
513
+ /**
514
+ * The status code of the response.
515
+ */
516
+ readonly status: number;
517
+ /**
518
+ * The status message corresponding to the status code.
519
+ */
520
+ readonly statusText: string;
521
+ /**
522
+ * The response headers.
523
+ */
524
+ readonly headers: Headers_2;
525
+ /**
526
+ * Returns the response body in a form that conforms to the specified response body type.
527
+ *
528
+ * @param responseBodyType The type of the response body.
529
+ * Can be `text`, `json`, `binary`, `form-data`, `array-buffer`, `blob`, `readable-stream`, `buffer` or `stream`.
530
+ * The default response body type is `json`.
531
+ * @throws {DataTypeError} Response body does not conform to the specified response body type.
532
+ * @throws {UnsupportedOperationError} Response body type is not supported by the platform.
533
+ */
534
+ body<T extends keyof ResponseBodyTypes = 'json'>(responseBodyType?: T): ResponseBodyTypes[T];
535
+ }
536
+
537
+ /**
538
+ * Represents a situation when the response status is considered invalid by the status validator.
539
+ */
540
+ export declare interface HttpClientResponseError extends BaseError {
541
+ /**
542
+ * The error name.
543
+ */
544
+ readonly name: 'ResponseError';
545
+ /**
546
+ * The error root cause.
547
+ */
548
+ readonly cause?: any;
549
+ /**
550
+ * The response.
551
+ */
552
+ readonly response: HttpClientResponse;
553
+ }
554
+
555
+ /**
556
+ * Dedicated error class for errors related to response serialization.
557
+ * Thrown when received service response can't be deserialized.
558
+ **/
559
+ export declare class _InvalidResponseError extends _ApiClientError {
560
+ readonly isInvalidResponseError = true;
561
+ responseBody: any;
562
+ expectedType?: string;
563
+ nestedError?: Error;
564
+ response: any;
565
+ constructor(name: string, nestedError: Error | any | undefined, body: any, expectedType?: string, message?: string, response?: any);
566
+ }
567
+
568
+ /**
569
+ * ApiClientError type guard function.
570
+ * Does a structural check of the passed object.
571
+ * @example
572
+ * try {
573
+ * doSomething();
574
+ * } catch (e: unknown) {
575
+ * if(isApiClientError(e)) {
576
+ * handleTheError();
577
+ * }
578
+ * }
579
+ */
580
+ export declare function _isApiClientError(e: any): e is _ApiClientError;
581
+
582
+ /**
583
+ * APIGatewayError type guard function.
584
+ * Does a structural check of the passed object.
585
+ * @example
586
+ * try {
587
+ * doSomething();
588
+ * } catch (e: unknown) {
589
+ * if(isApiClientError(e)) {
590
+ * handleTheError();
591
+ * }
592
+ * }
593
+ */
594
+ export declare function _isApiGatewayError(e: any): e is _ApiGatewayError;
595
+
596
+ /**
597
+ * ClientRequestError type guard function.
598
+ * Does a structural check of the passed object.
599
+ * @example
600
+ * try {
601
+ * doSomething();
602
+ * } catch (e: unknown) {
603
+ * if(isClientRequestError(e)) {
604
+ * handleTheError();
605
+ * }
606
+ * }
607
+ */
608
+ export declare function _isClientRequestError<T = _ErrorResponseBody>(e: any): e is _ClientRequestError<T>;
609
+
610
+ export declare function isHttpClientAbortError(e: any): e is HttpClientAbortError;
611
+
612
+ export declare function isHttpClientNetworkError(e: any): e is HttpClientNetworkError;
613
+
614
+ export declare function isHttpClientRequestError(e: any): e is HttpClientRequestError;
615
+
616
+ export declare function isHttpClientResponseError(e: any): e is HttpClientResponseError;
617
+
618
+ /**
619
+ * InvalidResponseError type guard function.
620
+ * Does a structural check of the passed object.
621
+ *
622
+ * Also returns `true` for `DataTypeError` instances thrown when a response body can't be
623
+ * decoded as the expected type (e.g. the server returned `text/html` but the SDK requested
624
+ * `application/json`). Treating those as `InvalidResponseError` lets app code handle "the
625
+ * response didn't match the expected schema" with a single type guard.
626
+ *
627
+ * @example
628
+ * try {
629
+ * doSomething();
630
+ * } catch (e: unknown) {
631
+ * if (isInvalidResponseError(e)) {
632
+ * throw e;
633
+ * }
634
+ * }
635
+ */
636
+ export declare function _isInvalidResponseError(e: any): e is _InvalidResponseError;
637
+
638
+ /**
639
+ * Represents a JSON field.
640
+ */
641
+ export declare interface JsonFormDataRequestField {
642
+ /**
643
+ * A JSON field type discriminator.
644
+ */
645
+ type: 'json';
646
+ /**
647
+ * The name of the field.
648
+ */
649
+ name: string;
650
+ /**
651
+ * The content type of the data contained in `value`.
652
+ * The default content type for the JSON is 'application/json'.
653
+ */
654
+ contentType?: string;
655
+ /**
656
+ * The filename reported to the server.
657
+ * The default filename for the JSON is 'json'.
658
+ */
659
+ filename?: string;
660
+ /**
661
+ * The field's value.
662
+ */
663
+ value: any;
664
+ }
665
+
666
+ /**
667
+ * DO NOT USE - internal use only.
668
+ */
669
+ export declare class _OAuthHttpClient implements types.HttpClient {
670
+ private readonly config;
671
+ private oauthToken?;
672
+ constructor(config: _OAuthHttpClientConfig);
673
+ send<T extends keyof types.RequestBodyTypes = 'json'>(options: types.HttpClientRequestOptions<T>): Promise<types.HttpClientResponse>;
674
+ private requestToken;
675
+ }
676
+
677
+ /**
678
+ * DO NOT USE - internal use only.
679
+ */
680
+ export declare interface _OAuthHttpClientConfig {
681
+ clientId: string;
682
+ secret: string;
683
+ scopes: string[];
684
+ environmentUrl: string;
685
+ authUrl: string;
686
+ }
687
+
688
+ export declare const PlatformAbortController: {
689
+ new (): types.AbortController;
690
+ };
691
+
692
+ export declare type PlatformAbortController = InstanceType<typeof PlatformAbortController>;
693
+
694
+ export declare const PlatformAbortSignal: {
695
+ new (): types.AbortSignal;
696
+ };
697
+
698
+ export declare type PlatformAbortSignal = InstanceType<typeof PlatformAbortSignal>;
699
+
700
+ export declare abstract class PlatformBaseError extends Error implements types.BaseError {
701
+ readonly cause?: any;
702
+ protected constructor(message: string, cause?: any);
703
+ }
704
+
705
+ export declare class PlatformBinary implements types.Binary {
706
+ readonly data: Blob | ArrayBuffer | ReadableStream<Uint8Array>;
707
+ static fromText(text: string): PlatformBinary;
708
+ static fromJson(json: any): PlatformBinary;
709
+ static from(data: Blob | ArrayBuffer | ReadableStream<Uint8Array> | Buffer | stream.Readable): PlatformBinary;
710
+ private constructor();
711
+ get<T extends keyof types.DataTypes>(type: T): types.DataTypes[T];
712
+ }
713
+
714
+ export declare class PlatformDataTypeError extends PlatformBaseError implements types.DataTypeError {
715
+ readonly name = "DataTypeError";
716
+ constructor(message: string, cause?: any);
717
+ }
718
+
719
+ export declare class PlatformHttpClient implements types.HttpClient {
720
+ private _baseUrl;
721
+ private _defaultHeaders;
722
+ constructor(options?: HttpClientConfiguration);
723
+ /**
724
+ * Sets HTTP Client Instance baseUrl param to the incoming value `baseUrl`.
725
+ * @param baseUrl Base URL used in the request path.
726
+ */
727
+ _setBaseURL(baseUrl: string): void;
728
+ /**
729
+ * Sets HTTP Client Instance defaultHeaders param to the incoming value `defaultHeaders`.
730
+ * @param defaultHeaders HTTP Headers to be used in outgoing requests.
731
+ */
732
+ _setDefaultHeaders(defaultHeaders: Headers_2): void;
733
+ send<T extends keyof types.RequestBodyTypes = 'json'>(options: types.HttpClientRequestOptions<T>): Promise<types.HttpClientResponse>;
734
+ }
735
+
736
+ export declare class PlatformHttpClientAbortError extends Error implements types.HttpClientAbortError {
737
+ readonly cause: any;
738
+ readonly name = "AbortError";
739
+ constructor(cause: any);
740
+ }
741
+
742
+ export declare class PlatformHttpClientRequestError extends PlatformBaseError implements types.HttpClientRequestError {
743
+ readonly cause: any;
744
+ readonly name = "RequestError";
745
+ constructor(cause: any);
746
+ }
747
+
748
+ export declare class PlatformHttpClientResponse implements types.HttpClientResponse {
749
+ private response;
750
+ readonly requestUrl: string;
751
+ constructor(response: Response, data?: {
752
+ requestUrl: string;
753
+ });
754
+ get url(): string;
755
+ get status(): number;
756
+ get statusText(): string;
757
+ get headers(): types.Headers;
758
+ body<T extends keyof types.ResponseBodyTypes = 'json'>(responseBodyType?: T): types.ResponseBodyTypes[T];
759
+ }
760
+
761
+ export declare class PlatformHttpClientResponseError extends PlatformBaseError implements types.HttpClientResponseError {
762
+ readonly name = "ResponseError";
763
+ readonly response: PlatformHttpClientResponse;
764
+ readonly requestMethod?: string;
765
+ constructor(response: Response, data?: {
766
+ requestUrl?: string;
767
+ requestMethod?: string;
768
+ });
769
+ }
770
+
771
+ export declare class PlatformUnsupportedOperationError extends PlatformBaseError implements types.UnsupportedOperationError {
772
+ readonly name = "UnsupportedOperationError";
773
+ constructor(message: string, cause?: any);
774
+ }
775
+
776
+ /**
777
+ * Mapping between the request body type names and types.
778
+ */
779
+ export declare type RequestBodyTypes = {
780
+ /**
781
+ * A text request body type.
782
+ */
783
+ text: string;
784
+ /**
785
+ * A JSON request body type.
786
+ */
787
+ json: any;
788
+ /**
789
+ * A multipart/form-data request body type.
790
+ */
791
+ 'form-data': FormDataRequestBody;
792
+ /**
793
+ * A binary request body type.
794
+ */
795
+ binary: Binary | ArrayBuffer | Blob | ReadableStream | Buffer | stream.Readable;
796
+ };
797
+
798
+ /**
799
+ * Resolves the body type used to decode a response. A fixed type, `'none'` to skip decoding
800
+ * entirely, or a callback invoked with the response to resolve it dynamically, for example from
801
+ * its content type.
802
+ */
803
+ export declare type _ResponseBodyTypeResolver = keyof ResponseBodyTypes | 'none' | ((response: HttpClientResponse) => keyof ResponseBodyTypes | 'none');
804
+
805
+ /**
806
+ * Mapping between the response body type names and types.
807
+ */
808
+ export declare type ResponseBodyTypes = {
809
+ /**
810
+ * A text response body type.
811
+ */
812
+ text: Promise<string>;
813
+ /**
814
+ * A JSON response body type.
815
+ */
816
+ json: Promise<any>;
817
+ /**
818
+ * A binary body type.
819
+ */
820
+ binary: Promise<Binary>;
821
+ /**
822
+ * A multipart/form-data body type.
823
+ */
824
+ 'form-data': Promise<FormDataResponseBody>;
825
+ /**
826
+ * An ArrayBuffer response body type.
827
+ */
828
+ 'array-buffer': Promise<ArrayBuffer>;
829
+ /**
830
+ * A Blob response body type. Browser only.
831
+ */
832
+ blob: Promise<Blob>;
833
+ /**
834
+ * A ReadableStream response body type. Browser only.
835
+ */
836
+ 'readable-stream': ReadableStream<Uint8Array>;
837
+ /**
838
+ * A Buffer response body type. Node only.
839
+ */
840
+ buffer: Promise<Buffer>;
841
+ /**
842
+ * A Stream response body type. Node only.
843
+ */
844
+ stream: stream.Readable;
845
+ };
846
+
847
+ /**
848
+ * Represents a function used to validate the response status code.
849
+ * If `true` is returned, the status is considered valid (request succeeded), otherwise it's considered invalid (request failed).
850
+ */
851
+ export declare interface StatusValidator {
852
+ (status: number): boolean;
853
+ }
854
+
855
+ /**
856
+ * Represents a plain text field. No filename and content type is set.
857
+ */
858
+ export declare interface TextFormDataRequestField {
859
+ /**
860
+ * A plain text field type discriminator.
861
+ */
862
+ type: 'text';
863
+ /**
864
+ * The name of the field.
865
+ */
866
+ name: string;
867
+ /**
868
+ * The field's value.
869
+ */
870
+ value: string;
871
+ }
872
+
873
+ export declare interface TextFormDataResponseField {
874
+ type: 'text';
875
+ name: string;
876
+ value: string;
877
+ }
878
+
879
+ declare namespace types {
880
+ export {
881
+ BaseError,
882
+ isHttpClientRequestError,
883
+ HttpClientRequestError,
884
+ UnsupportedOperationError,
885
+ StatusValidator,
886
+ ResponseBodyTypes,
887
+ HttpClient,
888
+ HttpClientResponse,
889
+ DataTypes,
890
+ HttpClientRequestOptions,
891
+ isHttpClientAbortError,
892
+ HttpClientAbortError,
893
+ AbortController_2 as AbortController,
894
+ TextFormDataResponseField,
895
+ BinaryFormDataResponseField,
896
+ FormDataResponseField,
897
+ FormDataResponseBody,
898
+ AbortSignal_2 as AbortSignal,
899
+ isHttpClientResponseError,
900
+ HttpClientResponseError,
901
+ TextFormDataRequestField,
902
+ JsonFormDataRequestField,
903
+ BinaryFormDataRequestField,
904
+ FormDataRequestField,
905
+ FormDataRequestBody,
906
+ Binary,
907
+ Headers_2 as Headers,
908
+ RequestBodyTypes,
909
+ DataTypeError,
910
+ isHttpClientNetworkError,
911
+ HttpClientNetworkError,
912
+ _ErrorType as ErrorType,
913
+ _ErrorResponseBody as ErrorResponseBody,
914
+ _CommonApiError as CommonApiError,
915
+ _CommonErrorDetails as CommonErrorDetails,
916
+ _ConstraintViolation as ConstraintViolation,
917
+ _ResponseBodyTypeResolver as ResponseBodyTypeResolver,
918
+ _ErrorResponseFactory as ErrorResponseFactory,
919
+ _ExecuteRequestOptions as ExecuteRequestOptions
920
+ }
921
+ }
922
+
923
+ export declare interface UnsupportedOperationError extends BaseError {
924
+ /**
925
+ * The error name.
926
+ */
927
+ readonly name: 'UnsupportedOperationError';
928
+ /**
929
+ * The error root cause.
930
+ */
931
+ readonly cause?: any;
932
+ }
933
+
934
+ export { }