@dynatrace-sdk/http-client 1.4.0 → 1.5.2
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 +28 -0
- package/cjs/index.js +32 -14
- package/docs/DOCS.md +101 -97
- package/esm/index.js +29 -11
- package/esm/package.json +3 -0
- package/package.json +13 -2
- 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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
@dynatrace-sdk/http-client
|
|
4
4
|
|
|
5
|
+
## 1.5.2
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- Published packages now include an `exports` map in their `package.json` (with `types`, `require` and `import` conditions), so Node.js resolves the `esm/` output as native ES modules. Previously the `module` field was only honoured by bundlers, so the `type: module` marker in `esm/package.json` had no effect in plain Node.js ESM resolution. Deep imports into `cjs/`, `esm/` or `types/` that are not listed in the map are no longer permitted.
|
|
10
|
+
- A `package.json` containing `{"type":"module"}` is now emitted into the `esm/` output directory of each published package. This allows Node.js and bundlers to correctly identify the ESM output as ES modules without requiring the `.mjs` file extension.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
- @dynatrace-sdk/error-handlers@1.3.3
|
|
16
|
+
|
|
17
|
+
## 1.5.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Make `data` constructor argument optional in `HttpClientResponse` and `HttpClientResponseError`, falling back to `response.url` when `requestUrl` is not provided. Restores backward compatibility broken in v1.5.0. (APPDEV-17720)
|
|
22
|
+
|
|
23
|
+
## 1.5.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- Add `requestUrl` to `HttpClientResponse` so the originally requested URL is preserved (and surfaced in error logs) even when `fetch` follows a redirect. (APPDEV-16083)
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Generated TypeScript declarations are now rolled up into a single `types/index.d.ts` per entry point. (APPDEV-11700)
|
|
32
|
+
|
|
5
33
|
## 1.4.0
|
|
6
34
|
|
|
7
35
|
### Minor Changes
|
package/cjs/index.js
CHANGED
|
@@ -33,8 +33,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
33
33
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
34
|
|
|
35
35
|
// packages/http-client/src/index.ts
|
|
36
|
-
var
|
|
37
|
-
__export(
|
|
36
|
+
var index_exports = {};
|
|
37
|
+
__export(index_exports, {
|
|
38
38
|
PlatformAbortController: () => AbortController,
|
|
39
39
|
PlatformAbortSignal: () => AbortSignal,
|
|
40
40
|
PlatformBaseError: () => BaseError,
|
|
@@ -53,7 +53,7 @@ __export(src_exports, {
|
|
|
53
53
|
isHttpClientRequestError: () => isHttpClientRequestError,
|
|
54
54
|
isHttpClientResponseError: () => isHttpClientResponseError
|
|
55
55
|
});
|
|
56
|
-
module.exports = __toCommonJS(
|
|
56
|
+
module.exports = __toCommonJS(index_exports);
|
|
57
57
|
|
|
58
58
|
// packages/http-client/src/lib/types/http-client-request-error.ts
|
|
59
59
|
function isHttpClientRequestError(e) {
|
|
@@ -87,6 +87,7 @@ var BaseError = class extends Error {
|
|
|
87
87
|
super(message);
|
|
88
88
|
this.cause = cause;
|
|
89
89
|
}
|
|
90
|
+
cause;
|
|
90
91
|
};
|
|
91
92
|
|
|
92
93
|
// packages/http-client/src/lib/platform/unsupported-operation-error.ts
|
|
@@ -118,6 +119,7 @@ var Binary = class _Binary {
|
|
|
118
119
|
constructor(data) {
|
|
119
120
|
this.data = data;
|
|
120
121
|
}
|
|
122
|
+
data;
|
|
121
123
|
static fromText(text) {
|
|
122
124
|
return new _Binary(new Blob([text]));
|
|
123
125
|
}
|
|
@@ -279,6 +281,7 @@ var HttpClientAbortError = class extends Error {
|
|
|
279
281
|
);
|
|
280
282
|
this.cause = cause;
|
|
281
283
|
}
|
|
284
|
+
cause;
|
|
282
285
|
name = "AbortError";
|
|
283
286
|
};
|
|
284
287
|
var throwIfAbortError = (e) => {
|
|
@@ -295,21 +298,20 @@ var HttpClientRequestError = class extends BaseError {
|
|
|
295
298
|
);
|
|
296
299
|
this.cause = cause;
|
|
297
300
|
}
|
|
301
|
+
cause;
|
|
298
302
|
name = "RequestError";
|
|
299
303
|
};
|
|
300
304
|
|
|
301
305
|
// packages/http-client/src/lib/platform/decode-form-data.ts
|
|
302
306
|
function byteToChar(byte) {
|
|
303
|
-
if (byte === void 0)
|
|
304
|
-
return void 0;
|
|
307
|
+
if (byte === void 0) return void 0;
|
|
305
308
|
return String.fromCharCode(byte);
|
|
306
309
|
}
|
|
307
310
|
function isTextContentType(contentType) {
|
|
308
311
|
return ["application/json", "text/plain"].includes(String(contentType).toLowerCase());
|
|
309
312
|
}
|
|
310
313
|
function removeEscaping(value) {
|
|
311
|
-
if (!value)
|
|
312
|
-
return value;
|
|
314
|
+
if (!value) return value;
|
|
313
315
|
return JSON.parse(`"${value}"`);
|
|
314
316
|
}
|
|
315
317
|
function parseContentDisposition(contentDisposition) {
|
|
@@ -329,6 +331,8 @@ var FormDataParser = class {
|
|
|
329
331
|
this.sourceArray = sourceArray;
|
|
330
332
|
this.boundary = boundary;
|
|
331
333
|
}
|
|
334
|
+
sourceArray;
|
|
335
|
+
boundary;
|
|
332
336
|
currentChar = null;
|
|
333
337
|
currentByte = null;
|
|
334
338
|
offset = 0;
|
|
@@ -636,9 +640,12 @@ function decodeResponseBody(response, responseBodyType) {
|
|
|
636
640
|
|
|
637
641
|
// packages/http-client/src/lib/platform/http-client-response.ts
|
|
638
642
|
var HttpClientResponse = class {
|
|
639
|
-
constructor(response) {
|
|
643
|
+
constructor(response, data) {
|
|
640
644
|
this.response = response;
|
|
645
|
+
this.requestUrl = data?.requestUrl ?? response.url;
|
|
641
646
|
}
|
|
647
|
+
response;
|
|
648
|
+
requestUrl;
|
|
642
649
|
get url() {
|
|
643
650
|
return this.response.url;
|
|
644
651
|
}
|
|
@@ -717,6 +724,7 @@ var httpClientResponseErrorSerializer = async (error) => {
|
|
|
717
724
|
type: import_error_handlers.ErrorType.HTTP,
|
|
718
725
|
details: {
|
|
719
726
|
url: error.response.url,
|
|
727
|
+
requestUrl: error.response.requestUrl,
|
|
720
728
|
method: error.requestMethod,
|
|
721
729
|
errorCode,
|
|
722
730
|
responseContentType: getHeaderValue(error.response, "content-type"),
|
|
@@ -750,7 +758,9 @@ var HttpClientResponseError = class extends BaseError {
|
|
|
750
758
|
constructor(response, data) {
|
|
751
759
|
addHttpClientResponseErrorSerializer();
|
|
752
760
|
super(`HTTP Error ${response.status}: ${response.statusText}`);
|
|
753
|
-
this.response = new HttpClientResponse(response
|
|
761
|
+
this.response = new HttpClientResponse(response, {
|
|
762
|
+
requestUrl: data?.requestUrl ?? response.url
|
|
763
|
+
});
|
|
754
764
|
this.requestMethod = data?.requestMethod;
|
|
755
765
|
}
|
|
756
766
|
};
|
|
@@ -799,9 +809,12 @@ var HttpClient = class {
|
|
|
799
809
|
});
|
|
800
810
|
const ok = statusValidator(response.status);
|
|
801
811
|
if (ok) {
|
|
802
|
-
return new HttpClientResponse(response);
|
|
812
|
+
return new HttpClientResponse(response, { requestUrl: url });
|
|
803
813
|
} else {
|
|
804
|
-
throw new HttpClientResponseError(response, {
|
|
814
|
+
throw new HttpClientResponseError(response, {
|
|
815
|
+
requestUrl: url,
|
|
816
|
+
requestMethod: options.method
|
|
817
|
+
});
|
|
805
818
|
}
|
|
806
819
|
}
|
|
807
820
|
};
|
|
@@ -849,6 +862,7 @@ var OAuthHttpClient = class {
|
|
|
849
862
|
constructor(config) {
|
|
850
863
|
this.config = config;
|
|
851
864
|
}
|
|
865
|
+
config;
|
|
852
866
|
oauthToken;
|
|
853
867
|
async send(options) {
|
|
854
868
|
const { statusValidator = defaultStatusValidator } = options;
|
|
@@ -862,7 +876,8 @@ var OAuthHttpClient = class {
|
|
|
862
876
|
...applyContentTypeHeader(options.headers, requestBodyType),
|
|
863
877
|
Authorization: `${this.oauthToken.tokenType} ${this.oauthToken.accessToken}`
|
|
864
878
|
};
|
|
865
|
-
const
|
|
879
|
+
const requestUrl = url.toString();
|
|
880
|
+
const response = await send2(requestUrl, {
|
|
866
881
|
method: options.method,
|
|
867
882
|
signal: options.abortSignal,
|
|
868
883
|
body,
|
|
@@ -870,9 +885,12 @@ var OAuthHttpClient = class {
|
|
|
870
885
|
});
|
|
871
886
|
const ok = statusValidator(response.status);
|
|
872
887
|
if (ok) {
|
|
873
|
-
return new HttpClientResponse(response);
|
|
888
|
+
return new HttpClientResponse(response, { requestUrl });
|
|
874
889
|
} else {
|
|
875
|
-
throw new HttpClientResponseError(response, {
|
|
890
|
+
throw new HttpClientResponseError(response, {
|
|
891
|
+
requestUrl,
|
|
892
|
+
requestMethod: options.method
|
|
893
|
+
});
|
|
876
894
|
}
|
|
877
895
|
}
|
|
878
896
|
async requestToken() {
|