@dynatrace-sdk/http-client 1.4.0 → 1.5.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.
- package/CHANGELOG.md +16 -0
- package/cjs/index.js +19 -7
- package/docs/DOCS.md +14 -10
- package/esm/index.js +19 -7
- package/package.json +1 -1
- package/types/index.d.ts +617 -1
- package/types/packages/http-client/src/index.d.ts +0 -2
- package/types/packages/http-client/src/lib/platform/abort-controller.d.ts +0 -6
- package/types/packages/http-client/src/lib/platform/abort-signal.d.ts +0 -6
- package/types/packages/http-client/src/lib/platform/apply-content-type-header.d.ts +0 -2
- package/types/packages/http-client/src/lib/platform/base-error.d.ts +0 -5
- package/types/packages/http-client/src/lib/platform/binary.d.ts +0 -13
- package/types/packages/http-client/src/lib/platform/data-type-error.d.ts +0 -6
- package/types/packages/http-client/src/lib/platform/decode-form-data.d.ts +0 -48
- package/types/packages/http-client/src/lib/platform/decode-response-body.d.ts +0 -3
- package/types/packages/http-client/src/lib/platform/default-status-validator.d.ts +0 -2
- package/types/packages/http-client/src/lib/platform/encode-request-body.d.ts +0 -2
- package/types/packages/http-client/src/lib/platform/http-client-abort-error.d.ts +0 -7
- package/types/packages/http-client/src/lib/platform/http-client-request-error.d.ts +0 -7
- package/types/packages/http-client/src/lib/platform/http-client-response-error-serializer.d.ts +0 -3
- package/types/packages/http-client/src/lib/platform/http-client-response-error.d.ts +0 -11
- package/types/packages/http-client/src/lib/platform/http-client-response.d.ts +0 -10
- package/types/packages/http-client/src/lib/platform/http-client.d.ts +0 -24
- package/types/packages/http-client/src/lib/platform/index.d.ts +0 -12
- package/types/packages/http-client/src/lib/platform/oauth-http-client.d.ts +0 -41
- package/types/packages/http-client/src/lib/platform/unsupported-operation-error.d.ts +0 -6
- package/types/packages/http-client/src/lib/types/abort-controller.d.ts +0 -14
- package/types/packages/http-client/src/lib/types/abort-signal.d.ts +0 -18
- package/types/packages/http-client/src/lib/types/base-error.d.ts +0 -4
- package/types/packages/http-client/src/lib/types/binary.d.ts +0 -15
- package/types/packages/http-client/src/lib/types/data-type-error.d.ts +0 -14
- package/types/packages/http-client/src/lib/types/data-types.d.ts +0 -36
- package/types/packages/http-client/src/lib/types/form-data-request-body.d.ts +0 -83
- package/types/packages/http-client/src/lib/types/form-data-response-body.d.ts +0 -15
- package/types/packages/http-client/src/lib/types/headers.d.ts +0 -6
- package/types/packages/http-client/src/lib/types/http-client-abort-error.d.ts +0 -15
- package/types/packages/http-client/src/lib/types/http-client-network-error.d.ts +0 -15
- package/types/packages/http-client/src/lib/types/http-client-request-error.d.ts +0 -15
- package/types/packages/http-client/src/lib/types/http-client-request-options.d.ts +0 -42
- package/types/packages/http-client/src/lib/types/http-client-response-error.d.ts +0 -20
- package/types/packages/http-client/src/lib/types/http-client-response.d.ts +0 -33
- package/types/packages/http-client/src/lib/types/http-client.d.ts +0 -24
- package/types/packages/http-client/src/lib/types/index.d.ts +0 -20
- package/types/packages/http-client/src/lib/types/request-body-types.d.ts +0 -26
- package/types/packages/http-client/src/lib/types/response-body-types.d.ts +0 -46
- package/types/packages/http-client/src/lib/types/status-validator.d.ts +0 -7
- package/types/packages/http-client/src/lib/types/unsupported-operation-error.d.ts +0 -14
package/types/index.d.ts
CHANGED
|
@@ -1 +1,617 @@
|
|
|
1
|
-
|
|
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,2 +0,0 @@
|
|
|
1
|
-
export { AbortController, AbortSignal, BaseError, Binary, BinaryFormDataRequestField, BinaryFormDataResponseField, DataTypeError, DataTypes, FormDataRequestBody, FormDataRequestField, FormDataResponseBody, FormDataResponseField, Headers, HttpClient, HttpClientAbortError, HttpClientNetworkError, HttpClientRequestError, HttpClientRequestOptions, HttpClientResponse, HttpClientResponseError, JsonFormDataRequestField, RequestBodyTypes, ResponseBodyTypes, StatusValidator, TextFormDataRequestField, TextFormDataResponseField, UnsupportedOperationError, isHttpClientResponseError, isHttpClientAbortError, isHttpClientNetworkError, isHttpClientRequestError, } from './lib/types';
|
|
2
|
-
export { AbortController as PlatformAbortController, AbortSignal as PlatformAbortSignal, BaseError as PlatformBaseError, Binary as PlatformBinary, DataTypeError as PlatformDataTypeError, HttpClient as PlatformHttpClient, HttpClientAbortError as PlatformHttpClientAbortError, HttpClientRequestError as PlatformHttpClientRequestError, HttpClientResponse as PlatformHttpClientResponse, HttpClientResponseError as PlatformHttpClientResponseError, OAuthHttpClient as _OAuthHttpClient, OAuthHttpClientConfig as _OAuthHttpClientConfig, UnsupportedOperationError as PlatformUnsupportedOperationError, httpClient, } from './lib/platform';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import type * as stream from 'stream';
|
|
4
|
-
import * as types from '../types';
|
|
5
|
-
export declare class Binary implements types.Binary {
|
|
6
|
-
readonly data: Blob | ArrayBuffer | ReadableStream<Uint8Array>;
|
|
7
|
-
static fromText(text: string): Binary;
|
|
8
|
-
static fromJson(json: any): Binary;
|
|
9
|
-
static from(data: Blob | ArrayBuffer | ReadableStream<Uint8Array> | Buffer | stream.Readable): Binary;
|
|
10
|
-
private constructor();
|
|
11
|
-
get<T extends keyof types.DataTypes>(type: T): types.DataTypes[T];
|
|
12
|
-
}
|
|
13
|
-
export declare function isBinary(body: any): body is Binary;
|