@sebspark/openapi-client 2.1.0 → 2.1.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/dist/index.js +12 -2
- package/dist/index.mjs +12 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -94,9 +94,15 @@ var paramsSerializer = (format) => (params) => {
|
|
|
94
94
|
// src/client.ts
|
|
95
95
|
var TypedClient = (baseURL, globalOptions, logger) => {
|
|
96
96
|
if (globalOptions?.authorizationTokenGenerator) {
|
|
97
|
+
logger?.debug("Authorization token generator is set");
|
|
97
98
|
import_axios.default.interceptors.request.use(async (request) => {
|
|
98
|
-
if (globalOptions?.authorizationTokenGenerator) {
|
|
99
|
+
if (globalOptions?.authorizationTokenGenerator && request.url) {
|
|
99
100
|
const authorizationTokenHeaders = await globalOptions.authorizationTokenGenerator(request.url);
|
|
101
|
+
logger?.debug(
|
|
102
|
+
"Authorization token headers",
|
|
103
|
+
authorizationTokenHeaders,
|
|
104
|
+
request.url
|
|
105
|
+
);
|
|
100
106
|
if (authorizationTokenHeaders) {
|
|
101
107
|
for (const [key, value] of Object.entries(
|
|
102
108
|
authorizationTokenHeaders
|
|
@@ -105,18 +111,22 @@ var TypedClient = (baseURL, globalOptions, logger) => {
|
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
}
|
|
114
|
+
logger?.debug("Request", request);
|
|
108
115
|
return request;
|
|
109
116
|
});
|
|
110
117
|
}
|
|
111
118
|
if (globalOptions?.authorizationTokenRefresh) {
|
|
112
119
|
const refreshAuthLogic = async (failedRequest) => {
|
|
120
|
+
logger?.debug("Failed request", failedRequest);
|
|
113
121
|
if (!import_axios.default.isAxiosError(failedRequest)) {
|
|
122
|
+
logger?.error("Failed request is not an axios error");
|
|
114
123
|
return;
|
|
115
124
|
}
|
|
116
125
|
const axiosError = failedRequest;
|
|
117
126
|
const url = `${axiosError.config?.baseURL}${axiosError.config?.url}`;
|
|
127
|
+
logger?.debug("Failed request config", axiosError.config);
|
|
118
128
|
if (globalOptions?.authorizationTokenRefresh && url) {
|
|
119
|
-
await globalOptions?.authorizationTokenRefresh(
|
|
129
|
+
await globalOptions?.authorizationTokenRefresh(url);
|
|
120
130
|
}
|
|
121
131
|
};
|
|
122
132
|
(0, import_axios_auth_refresh.default)(import_axios.default, refreshAuthLogic);
|
package/dist/index.mjs
CHANGED
|
@@ -59,9 +59,15 @@ var paramsSerializer = (format) => (params) => {
|
|
|
59
59
|
// src/client.ts
|
|
60
60
|
var TypedClient = (baseURL, globalOptions, logger) => {
|
|
61
61
|
if (globalOptions?.authorizationTokenGenerator) {
|
|
62
|
+
logger?.debug("Authorization token generator is set");
|
|
62
63
|
axios.interceptors.request.use(async (request) => {
|
|
63
|
-
if (globalOptions?.authorizationTokenGenerator) {
|
|
64
|
+
if (globalOptions?.authorizationTokenGenerator && request.url) {
|
|
64
65
|
const authorizationTokenHeaders = await globalOptions.authorizationTokenGenerator(request.url);
|
|
66
|
+
logger?.debug(
|
|
67
|
+
"Authorization token headers",
|
|
68
|
+
authorizationTokenHeaders,
|
|
69
|
+
request.url
|
|
70
|
+
);
|
|
65
71
|
if (authorizationTokenHeaders) {
|
|
66
72
|
for (const [key, value] of Object.entries(
|
|
67
73
|
authorizationTokenHeaders
|
|
@@ -70,18 +76,22 @@ var TypedClient = (baseURL, globalOptions, logger) => {
|
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
}
|
|
79
|
+
logger?.debug("Request", request);
|
|
73
80
|
return request;
|
|
74
81
|
});
|
|
75
82
|
}
|
|
76
83
|
if (globalOptions?.authorizationTokenRefresh) {
|
|
77
84
|
const refreshAuthLogic = async (failedRequest) => {
|
|
85
|
+
logger?.debug("Failed request", failedRequest);
|
|
78
86
|
if (!axios.isAxiosError(failedRequest)) {
|
|
87
|
+
logger?.error("Failed request is not an axios error");
|
|
79
88
|
return;
|
|
80
89
|
}
|
|
81
90
|
const axiosError = failedRequest;
|
|
82
91
|
const url = `${axiosError.config?.baseURL}${axiosError.config?.url}`;
|
|
92
|
+
logger?.debug("Failed request config", axiosError.config);
|
|
83
93
|
if (globalOptions?.authorizationTokenRefresh && url) {
|
|
84
|
-
await globalOptions?.authorizationTokenRefresh(
|
|
94
|
+
await globalOptions?.authorizationTokenRefresh(url);
|
|
85
95
|
}
|
|
86
96
|
};
|
|
87
97
|
createAuthRefreshInterceptor(axios, refreshAuthLogic);
|