@ethlete/query 0.1.0-next.1 → 0.1.0-next.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.
@@ -164,13 +164,15 @@ const buildTimestampFromSeconds = (seconds) => {
164
164
  }
165
165
  return new Date(Date.now() + seconds * 1000).getTime();
166
166
  };
167
- const buildRequestError = async (error) => {
167
+ const buildRequestError = async (error, route, requestInit) => {
168
168
  if (error instanceof DOMException && error.code === error.ABORT_ERR) {
169
169
  const err = {
170
170
  code: -1,
171
171
  message: 'Request aborted',
172
172
  detail: null,
173
173
  raw: error,
174
+ route,
175
+ requestInit,
174
176
  };
175
177
  return err;
176
178
  }
@@ -180,6 +182,8 @@ const buildRequestError = async (error) => {
180
182
  message: 'Syntax error',
181
183
  detail: null,
182
184
  raw: error,
185
+ route,
186
+ requestInit,
183
187
  };
184
188
  return err;
185
189
  }
@@ -189,6 +193,8 @@ const buildRequestError = async (error) => {
189
193
  message: `${error.name}: ${error.message}`,
190
194
  detail: null,
191
195
  raw: error,
196
+ route,
197
+ requestInit,
192
198
  };
193
199
  return err;
194
200
  }
@@ -206,6 +212,8 @@ const buildRequestError = async (error) => {
206
212
  message: error.statusText,
207
213
  detail,
208
214
  raw: error,
215
+ route,
216
+ requestInit,
209
217
  };
210
218
  return err;
211
219
  }
@@ -214,6 +222,8 @@ const buildRequestError = async (error) => {
214
222
  message: 'Unknown error',
215
223
  detail: null,
216
224
  raw: error,
225
+ route,
226
+ requestInit,
217
227
  };
218
228
  return err;
219
229
  };
@@ -268,7 +278,7 @@ const request = async (options) => {
268
278
  return { data, expiresInTimestamp };
269
279
  }
270
280
  catch (error) {
271
- throw await buildRequestError(error);
281
+ throw await buildRequestError(error, options.route, options.init);
272
282
  }
273
283
  };
274
284
 
@@ -345,11 +355,12 @@ class BearerAuthProvider {
345
355
  route,
346
356
  });
347
357
  const body = bodyAdapter ? bodyAdapter(this._refreshToken) : { refreshToken: this._refreshToken };
358
+ const requestInit = { body: buildBody(body), method };
348
359
  this.onRefreshInitiation$.next();
349
360
  try {
350
361
  const result = await request({
351
362
  route: fullRoute,
352
- init: { body: buildBody(body), method },
363
+ init: requestInit,
353
364
  });
354
365
  const tokens = responseAdapter ? responseAdapter(result.data) : result.data;
355
366
  if (!tokens.token) {
@@ -364,7 +375,7 @@ class BearerAuthProvider {
364
375
  }
365
376
  catch (error) {
366
377
  if (error instanceof Error) {
367
- this.onRefreshFailure$.next(await buildRequestError(error));
378
+ this.onRefreshFailure$.next(await buildRequestError(error, fullRoute, requestInit));
368
379
  }
369
380
  else {
370
381
  this.onRefreshFailure$.next(error);