@sebspark/openapi-client 2.1.9 → 2.2.0

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 CHANGED
@@ -100,13 +100,18 @@ var TypedClient = (baseURL, globalOptions, logger) => {
100
100
  const url = `${request.baseURL}${request.url}`;
101
101
  logger?.debug(`Intercepting request to ${url}`);
102
102
  if (globalOptions?.authorizationTokenGenerator && url) {
103
- const authorizationTokenHeaders = await globalOptions.authorizationTokenGenerator(url);
104
- if (authorizationTokenHeaders) {
105
- for (const key of Object.keys(authorizationTokenHeaders)) {
106
- const value = authorizationTokenHeaders[key];
107
- logger?.debug(`Setting header ${key} to ${value}`);
108
- request.headers[key] = value;
103
+ try {
104
+ const authorizationTokenHeaders = await globalOptions.authorizationTokenGenerator(url);
105
+ if (authorizationTokenHeaders) {
106
+ for (const key of Object.keys(authorizationTokenHeaders)) {
107
+ const value = authorizationTokenHeaders[key];
108
+ logger?.debug(`Setting header ${key} to ${value}`);
109
+ request.headers[key] = value;
110
+ }
109
111
  }
112
+ } catch (error) {
113
+ logger?.error(`Error generating token for URL: ${url}`);
114
+ throw error;
110
115
  }
111
116
  }
112
117
  logger?.debug("Intercepted request:");
@@ -128,7 +133,12 @@ var TypedClient = (baseURL, globalOptions, logger) => {
128
133
  const url = `${axiosError.config?.baseURL}${axiosError.config?.url}`;
129
134
  if (globalOptions?.authorizationTokenRefresh && url) {
130
135
  logger?.debug(`Refreshing token for URL ${url}`);
131
- await globalOptions?.authorizationTokenRefresh(url);
136
+ try {
137
+ await globalOptions?.authorizationTokenRefresh(url);
138
+ } catch (error) {
139
+ logger?.error(`Error refreshing token for URL: ${url}`);
140
+ throw error;
141
+ }
132
142
  }
133
143
  };
134
144
  (0, import_axios_auth_refresh.default)(axiosInstance, refreshAuthLogic);
@@ -191,7 +201,8 @@ var callServer = async (axiosInstance, args) => {
191
201
  paramsSerializer: serializer,
192
202
  data: body,
193
203
  httpsAgent: args.httpsAgent,
194
- httpAgent: args.httpAgent
204
+ httpAgent: args.httpAgent,
205
+ timeout: args.timeout
195
206
  }),
196
207
  args.retry
197
208
  );
@@ -216,7 +227,8 @@ var mergeArgs = (baseUrl, url, method, requestArgs, extras, global) => {
216
227
  retry: retry2,
217
228
  arrayFormat: global?.arrayFormat,
218
229
  httpsAgent: extras?.httpsAgent,
219
- httpAgent: extras?.httpAgent
230
+ httpAgent: extras?.httpAgent,
231
+ timeout: extras?.timeout ?? global?.timeout
220
232
  };
221
233
  return merged;
222
234
  };
package/dist/index.mjs CHANGED
@@ -65,13 +65,18 @@ var TypedClient = (baseURL, globalOptions, logger) => {
65
65
  const url = `${request.baseURL}${request.url}`;
66
66
  logger?.debug(`Intercepting request to ${url}`);
67
67
  if (globalOptions?.authorizationTokenGenerator && url) {
68
- const authorizationTokenHeaders = await globalOptions.authorizationTokenGenerator(url);
69
- if (authorizationTokenHeaders) {
70
- for (const key of Object.keys(authorizationTokenHeaders)) {
71
- const value = authorizationTokenHeaders[key];
72
- logger?.debug(`Setting header ${key} to ${value}`);
73
- request.headers[key] = value;
68
+ try {
69
+ const authorizationTokenHeaders = await globalOptions.authorizationTokenGenerator(url);
70
+ if (authorizationTokenHeaders) {
71
+ for (const key of Object.keys(authorizationTokenHeaders)) {
72
+ const value = authorizationTokenHeaders[key];
73
+ logger?.debug(`Setting header ${key} to ${value}`);
74
+ request.headers[key] = value;
75
+ }
74
76
  }
77
+ } catch (error) {
78
+ logger?.error(`Error generating token for URL: ${url}`);
79
+ throw error;
75
80
  }
76
81
  }
77
82
  logger?.debug("Intercepted request:");
@@ -93,7 +98,12 @@ var TypedClient = (baseURL, globalOptions, logger) => {
93
98
  const url = `${axiosError.config?.baseURL}${axiosError.config?.url}`;
94
99
  if (globalOptions?.authorizationTokenRefresh && url) {
95
100
  logger?.debug(`Refreshing token for URL ${url}`);
96
- await globalOptions?.authorizationTokenRefresh(url);
101
+ try {
102
+ await globalOptions?.authorizationTokenRefresh(url);
103
+ } catch (error) {
104
+ logger?.error(`Error refreshing token for URL: ${url}`);
105
+ throw error;
106
+ }
97
107
  }
98
108
  };
99
109
  createAuthRefreshInterceptor(axiosInstance, refreshAuthLogic);
@@ -156,7 +166,8 @@ var callServer = async (axiosInstance, args) => {
156
166
  paramsSerializer: serializer,
157
167
  data: body,
158
168
  httpsAgent: args.httpsAgent,
159
- httpAgent: args.httpAgent
169
+ httpAgent: args.httpAgent,
170
+ timeout: args.timeout
160
171
  }),
161
172
  args.retry
162
173
  );
@@ -181,7 +192,8 @@ var mergeArgs = (baseUrl, url, method, requestArgs, extras, global) => {
181
192
  retry: retry2,
182
193
  arrayFormat: global?.arrayFormat,
183
194
  httpsAgent: extras?.httpsAgent,
184
- httpAgent: extras?.httpAgent
195
+ httpAgent: extras?.httpAgent,
196
+ timeout: extras?.timeout ?? global?.timeout
185
197
  };
186
198
  return merged;
187
199
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebspark/openapi-client",
3
- "version": "2.1.9",
3
+ "version": "2.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",