@meistrari/tela-sdk-js 2.3.0 → 2.3.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/dist/index.cjs +29 -2
- package/dist/index.mjs +29 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ const z__default = /*#__PURE__*/_interopDefaultCompat(z);
|
|
|
24
24
|
const z__namespace = /*#__PURE__*/_interopNamespaceCompat(z);
|
|
25
25
|
const Emittery__default = /*#__PURE__*/_interopDefaultCompat(Emittery);
|
|
26
26
|
|
|
27
|
-
const version = "2.3.
|
|
27
|
+
const version = "2.3.1";
|
|
28
28
|
|
|
29
29
|
var __defProp$7 = Object.defineProperty;
|
|
30
30
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -739,6 +739,33 @@ var __publicField$5 = (obj, key, value) => {
|
|
|
739
739
|
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
740
740
|
return value;
|
|
741
741
|
};
|
|
742
|
+
function tryGetResponseHeaders(response) {
|
|
743
|
+
try {
|
|
744
|
+
if (typeof response.headers.toJSON === "function") {
|
|
745
|
+
return response.headers.toJSON();
|
|
746
|
+
}
|
|
747
|
+
if ("entries" in response.headers && typeof response.headers.entries === "function") {
|
|
748
|
+
return Object.fromEntries(response.headers.entries());
|
|
749
|
+
}
|
|
750
|
+
if (typeof response.headers.forEach === "function") {
|
|
751
|
+
const headers = {};
|
|
752
|
+
response.headers.forEach((value, key) => {
|
|
753
|
+
headers[key] = value;
|
|
754
|
+
});
|
|
755
|
+
return headers;
|
|
756
|
+
}
|
|
757
|
+
if (response.headers && typeof response.headers[Symbol.iterator] === "function") {
|
|
758
|
+
const headers = {};
|
|
759
|
+
for (const [key, value] of response.headers) {
|
|
760
|
+
headers[key] = value;
|
|
761
|
+
}
|
|
762
|
+
return headers;
|
|
763
|
+
}
|
|
764
|
+
return {};
|
|
765
|
+
} catch {
|
|
766
|
+
return {};
|
|
767
|
+
}
|
|
768
|
+
}
|
|
742
769
|
async function defaultParseResponse(props) {
|
|
743
770
|
const { response } = props;
|
|
744
771
|
if (props.options.stream) {
|
|
@@ -753,7 +780,7 @@ async function defaultParseResponse(props) {
|
|
|
753
780
|
if (isJSON) {
|
|
754
781
|
const json = await response.json();
|
|
755
782
|
debug("response", response.status, response.url, response.headers, json);
|
|
756
|
-
return transformObjectFromSnakeCaseToCamelCase({ ...json, headers: response
|
|
783
|
+
return transformObjectFromSnakeCaseToCamelCase({ ...json, headers: tryGetResponseHeaders(response) }, DEFAULT_FIELDS_TRANSFORMATION_EXCLUSIONS);
|
|
757
784
|
}
|
|
758
785
|
const text = await response.text();
|
|
759
786
|
debug("response", response.status, response.url, response.headers, text);
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import * as z from 'zod';
|
|
|
4
4
|
import z__default, { z as z$1, ZodError } from 'zod';
|
|
5
5
|
import Emittery from 'emittery';
|
|
6
6
|
|
|
7
|
-
const version = "2.3.
|
|
7
|
+
const version = "2.3.1";
|
|
8
8
|
|
|
9
9
|
var __defProp$7 = Object.defineProperty;
|
|
10
10
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -719,6 +719,33 @@ var __publicField$5 = (obj, key, value) => {
|
|
|
719
719
|
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
720
720
|
return value;
|
|
721
721
|
};
|
|
722
|
+
function tryGetResponseHeaders(response) {
|
|
723
|
+
try {
|
|
724
|
+
if (typeof response.headers.toJSON === "function") {
|
|
725
|
+
return response.headers.toJSON();
|
|
726
|
+
}
|
|
727
|
+
if ("entries" in response.headers && typeof response.headers.entries === "function") {
|
|
728
|
+
return Object.fromEntries(response.headers.entries());
|
|
729
|
+
}
|
|
730
|
+
if (typeof response.headers.forEach === "function") {
|
|
731
|
+
const headers = {};
|
|
732
|
+
response.headers.forEach((value, key) => {
|
|
733
|
+
headers[key] = value;
|
|
734
|
+
});
|
|
735
|
+
return headers;
|
|
736
|
+
}
|
|
737
|
+
if (response.headers && typeof response.headers[Symbol.iterator] === "function") {
|
|
738
|
+
const headers = {};
|
|
739
|
+
for (const [key, value] of response.headers) {
|
|
740
|
+
headers[key] = value;
|
|
741
|
+
}
|
|
742
|
+
return headers;
|
|
743
|
+
}
|
|
744
|
+
return {};
|
|
745
|
+
} catch {
|
|
746
|
+
return {};
|
|
747
|
+
}
|
|
748
|
+
}
|
|
722
749
|
async function defaultParseResponse(props) {
|
|
723
750
|
const { response } = props;
|
|
724
751
|
if (props.options.stream) {
|
|
@@ -733,7 +760,7 @@ async function defaultParseResponse(props) {
|
|
|
733
760
|
if (isJSON) {
|
|
734
761
|
const json = await response.json();
|
|
735
762
|
debug("response", response.status, response.url, response.headers, json);
|
|
736
|
-
return transformObjectFromSnakeCaseToCamelCase({ ...json, headers: response
|
|
763
|
+
return transformObjectFromSnakeCaseToCamelCase({ ...json, headers: tryGetResponseHeaders(response) }, DEFAULT_FIELDS_TRANSFORMATION_EXCLUSIONS);
|
|
737
764
|
}
|
|
738
765
|
const text = await response.text();
|
|
739
766
|
debug("response", response.status, response.url, response.headers, text);
|