@shipengine/alchemy 6.0.69 → 6.0.70
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/index.js +24 -18
- package/index.mjs +24 -18
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -34512,7 +34512,7 @@ const logger$1 = E({
|
|
|
34512
34512
|
]
|
|
34513
34513
|
});
|
|
34514
34514
|
class ShipEngineAPI {
|
|
34515
|
-
constructor(token, { baseURL, headers, getToken, getSandboxToken, onApiError }) {
|
|
34515
|
+
constructor(token, { baseURL, debug = true, headers, getToken, getSandboxToken, onApiError }) {
|
|
34516
34516
|
this.getSandboxToken = getSandboxToken;
|
|
34517
34517
|
const client = axios.create({
|
|
34518
34518
|
baseURL,
|
|
@@ -34573,27 +34573,31 @@ class ShipEngineAPI {
|
|
|
34573
34573
|
client.interceptors.response.use(
|
|
34574
34574
|
(res) => {
|
|
34575
34575
|
var _a;
|
|
34576
|
-
|
|
34577
|
-
|
|
34578
|
-
|
|
34579
|
-
|
|
34580
|
-
|
|
34581
|
-
|
|
34582
|
-
|
|
34583
|
-
|
|
34576
|
+
if (debug) {
|
|
34577
|
+
logger$1.info(
|
|
34578
|
+
{ req: res.config, res },
|
|
34579
|
+
"%s %s: %s %s",
|
|
34580
|
+
(_a = res.config.method) == null ? void 0 : _a.toUpperCase(),
|
|
34581
|
+
res.config.url,
|
|
34582
|
+
res.status,
|
|
34583
|
+
res.statusText
|
|
34584
|
+
);
|
|
34585
|
+
}
|
|
34584
34586
|
return res;
|
|
34585
34587
|
},
|
|
34586
34588
|
(err) => __async$$(this, null, function* () {
|
|
34587
34589
|
var _a, _b, _c, _d, _e;
|
|
34588
|
-
|
|
34589
|
-
|
|
34590
|
-
|
|
34591
|
-
|
|
34592
|
-
|
|
34593
|
-
|
|
34594
|
-
|
|
34595
|
-
|
|
34596
|
-
|
|
34590
|
+
if (debug) {
|
|
34591
|
+
logger$1.error(
|
|
34592
|
+
{ err, req: err.config, res: err.response },
|
|
34593
|
+
"%s %s: %s %s - %s",
|
|
34594
|
+
(_b = (_a = err.config) == null ? void 0 : _a.method) == null ? void 0 : _b.toUpperCase(),
|
|
34595
|
+
(_c = err.config) == null ? void 0 : _c.url,
|
|
34596
|
+
(_d = err.response) == null ? void 0 : _d.status,
|
|
34597
|
+
(_e = err.response) == null ? void 0 : _e.statusText,
|
|
34598
|
+
err.message
|
|
34599
|
+
);
|
|
34600
|
+
}
|
|
34597
34601
|
if (isInvalidTokenError(err)) {
|
|
34598
34602
|
const token2 = yield err.config.isSandbox ? getSandboxToken == null ? void 0 : getSandboxToken() : getToken();
|
|
34599
34603
|
const config = err.config;
|
|
@@ -34880,6 +34884,7 @@ const ShipEngineContext = React.createContext(void 0);
|
|
|
34880
34884
|
const ShipEngine = ({
|
|
34881
34885
|
baseURL,
|
|
34882
34886
|
children,
|
|
34887
|
+
debug,
|
|
34883
34888
|
headers,
|
|
34884
34889
|
getSandboxToken,
|
|
34885
34890
|
getToken,
|
|
@@ -34896,6 +34901,7 @@ const ShipEngine = ({
|
|
|
34896
34901
|
const token = getToken();
|
|
34897
34902
|
const commonClientProps = {
|
|
34898
34903
|
baseURL,
|
|
34904
|
+
debug,
|
|
34899
34905
|
getSandboxToken,
|
|
34900
34906
|
getToken,
|
|
34901
34907
|
headers: headers != null ? headers : {},
|
package/index.mjs
CHANGED
|
@@ -34490,7 +34490,7 @@ const logger$1 = E({
|
|
|
34490
34490
|
]
|
|
34491
34491
|
});
|
|
34492
34492
|
class ShipEngineAPI {
|
|
34493
|
-
constructor(token, { baseURL, headers, getToken, getSandboxToken, onApiError }) {
|
|
34493
|
+
constructor(token, { baseURL, debug = true, headers, getToken, getSandboxToken, onApiError }) {
|
|
34494
34494
|
this.getSandboxToken = getSandboxToken;
|
|
34495
34495
|
const client = axios.create({
|
|
34496
34496
|
baseURL,
|
|
@@ -34551,27 +34551,31 @@ class ShipEngineAPI {
|
|
|
34551
34551
|
client.interceptors.response.use(
|
|
34552
34552
|
(res) => {
|
|
34553
34553
|
var _a;
|
|
34554
|
-
|
|
34555
|
-
|
|
34556
|
-
|
|
34557
|
-
|
|
34558
|
-
|
|
34559
|
-
|
|
34560
|
-
|
|
34561
|
-
|
|
34554
|
+
if (debug) {
|
|
34555
|
+
logger$1.info(
|
|
34556
|
+
{ req: res.config, res },
|
|
34557
|
+
"%s %s: %s %s",
|
|
34558
|
+
(_a = res.config.method) == null ? void 0 : _a.toUpperCase(),
|
|
34559
|
+
res.config.url,
|
|
34560
|
+
res.status,
|
|
34561
|
+
res.statusText
|
|
34562
|
+
);
|
|
34563
|
+
}
|
|
34562
34564
|
return res;
|
|
34563
34565
|
},
|
|
34564
34566
|
(err) => __async$$(this, null, function* () {
|
|
34565
34567
|
var _a, _b, _c, _d, _e;
|
|
34566
|
-
|
|
34567
|
-
|
|
34568
|
-
|
|
34569
|
-
|
|
34570
|
-
|
|
34571
|
-
|
|
34572
|
-
|
|
34573
|
-
|
|
34574
|
-
|
|
34568
|
+
if (debug) {
|
|
34569
|
+
logger$1.error(
|
|
34570
|
+
{ err, req: err.config, res: err.response },
|
|
34571
|
+
"%s %s: %s %s - %s",
|
|
34572
|
+
(_b = (_a = err.config) == null ? void 0 : _a.method) == null ? void 0 : _b.toUpperCase(),
|
|
34573
|
+
(_c = err.config) == null ? void 0 : _c.url,
|
|
34574
|
+
(_d = err.response) == null ? void 0 : _d.status,
|
|
34575
|
+
(_e = err.response) == null ? void 0 : _e.statusText,
|
|
34576
|
+
err.message
|
|
34577
|
+
);
|
|
34578
|
+
}
|
|
34575
34579
|
if (isInvalidTokenError(err)) {
|
|
34576
34580
|
const token2 = yield err.config.isSandbox ? getSandboxToken == null ? void 0 : getSandboxToken() : getToken();
|
|
34577
34581
|
const config = err.config;
|
|
@@ -34858,6 +34862,7 @@ const ShipEngineContext = createContext(void 0);
|
|
|
34858
34862
|
const ShipEngine = ({
|
|
34859
34863
|
baseURL,
|
|
34860
34864
|
children,
|
|
34865
|
+
debug,
|
|
34861
34866
|
headers,
|
|
34862
34867
|
getSandboxToken,
|
|
34863
34868
|
getToken,
|
|
@@ -34874,6 +34879,7 @@ const ShipEngine = ({
|
|
|
34874
34879
|
const token = getToken();
|
|
34875
34880
|
const commonClientProps = {
|
|
34876
34881
|
baseURL,
|
|
34882
|
+
debug,
|
|
34877
34883
|
getSandboxToken,
|
|
34878
34884
|
getToken,
|
|
34879
34885
|
headers: headers != null ? headers : {},
|