@overmap-ai/core 1.0.60-sdk-refactor.6 → 1.0.60-sdk-refactor.8

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.
@@ -15060,11 +15060,12 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15060
15060
  if (!serviceOfRequest) {
15061
15061
  throw new Error(`Service ${action.meta.offline.effect.serviceName} not found`);
15062
15062
  }
15063
+ const isApiService = serviceOfRequest instanceof BaseApiService;
15063
15064
  const state = client.store.getState();
15064
15065
  if (state.outboxReducer.deletedRequests.includes(action.payload.uuid)) {
15065
15066
  throw new Error("Request was marked for deletion");
15066
15067
  }
15067
- if (action.payload.checkAuth !== false) {
15068
+ if (isApiService && action.payload.checkAuth !== false) {
15068
15069
  await serviceOfRequest.auth.prepareAuth();
15069
15070
  }
15070
15071
  const defaultSettings = {
@@ -15130,7 +15131,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15130
15131
  };
15131
15132
  const selectedRequest = methodRequestMapping[method];
15132
15133
  let requestToSend = selectedRequest();
15133
- if (isAuthNeeded) {
15134
+ if (isAuthNeeded && isApiService) {
15134
15135
  const authHeader = serviceOfRequest.auth.getAuthHeader();
15135
15136
  requestToSend = requestToSend.set("Authorization", authHeader);
15136
15137
  }
@@ -15142,7 +15143,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15142
15143
  } catch (error2) {
15143
15144
  const errorResponse = extractResponseFromError(error2);
15144
15145
  const status = errorResponse == null ? void 0 : errorResponse.status;
15145
- if (status === 401) {
15146
+ if (isApiService && status === 401) {
15146
15147
  await serviceOfRequest.auth.handleUnauthorized(requestToSend, errorResponse);
15147
15148
  return requestToSend.query(queryParams);
15148
15149
  }
@@ -15398,9 +15399,11 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15398
15399
  setClientStore(store);
15399
15400
  return sdkInstance;
15400
15401
  };
15401
- class BaseAuthService {
15402
+ const CLASS_NAME_TO_SERVICE$1 = {};
15403
+ class BaseService {
15402
15404
  constructor(sdk) {
15403
15405
  __publicField(this, "client");
15406
+ CLASS_NAME_TO_SERVICE$1[this.constructor.name] = this;
15404
15407
  this.client = sdk;
15405
15408
  }
15406
15409
  async enqueueRequest(requestDetails) {
@@ -15410,6 +15413,11 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15410
15413
  this.client.store.dispatch(action);
15411
15414
  }
15412
15415
  }
15416
+ class BaseAuthService extends BaseService {
15417
+ constructor(sdk) {
15418
+ super(sdk);
15419
+ }
15420
+ }
15413
15421
  const EXPIRING_SOON_THRESHOLD = 1800;
15414
15422
  function parseTokens(response) {
15415
15423
  if (!response.access)
@@ -15445,14 +15453,14 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15445
15453
  immediate: true
15446
15454
  }).catch((e) => {
15447
15455
  console.error("Could not renew tokens; logging out due to error:", e);
15448
- void this.clearAuth();
15456
+ this.clearAuth();
15449
15457
  return void 0;
15450
15458
  });
15451
15459
  let response = void 0;
15452
15460
  try {
15453
15461
  response = await promise;
15454
15462
  } catch (e) {
15455
- await this.clearAuth();
15463
+ this.clearAuth();
15456
15464
  }
15457
15465
  if (!response)
15458
15466
  return void 0;
@@ -15466,15 +15474,13 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15466
15474
  /**
15467
15475
  * Logs the user out
15468
15476
  */
15469
- async clearAuth() {
15477
+ clearAuth() {
15470
15478
  this.dispatch(setLoggedIn(false));
15471
15479
  this.clearTokens();
15472
15480
  this.dispatch(setActiveProjectId(null));
15473
15481
  this.dispatch(setActiveWorkspaceId(null));
15474
15482
  this.dispatch({ type: constants.RESET_STATE });
15475
15483
  this.dispatch({ type: resetStore });
15476
- await localforage.clear();
15477
- window.location.reload();
15478
15484
  }
15479
15485
  /**
15480
15486
  * Attempts to renew tokens
@@ -15493,7 +15499,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15493
15499
  this.setTokens(tokens);
15494
15500
  } catch (e) {
15495
15501
  console.error("Could not renew tokens; logging out.");
15496
- await this.clearAuth();
15502
+ this.clearAuth();
15497
15503
  throw e;
15498
15504
  }
15499
15505
  }
@@ -15527,7 +15533,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15527
15533
  await this.renewTokens();
15528
15534
  } catch (e) {
15529
15535
  if (e instanceof APIError) {
15530
- await this.clearAuth();
15536
+ this.clearAuth();
15531
15537
  }
15532
15538
  return Promise.reject(e);
15533
15539
  }
@@ -15539,7 +15545,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15539
15545
  if (state.authReducer.isLoggedIn) {
15540
15546
  console.warn("No signed-in user to sign out.");
15541
15547
  }
15542
- await this.clearAuth();
15548
+ this.clearAuth();
15543
15549
  throw new APIError({
15544
15550
  message: "You have been signed out due to inactivity.",
15545
15551
  response,
@@ -15596,20 +15602,12 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
15596
15602
  }
15597
15603
  }
15598
15604
  const CLASS_NAME_TO_SERVICE = {};
15599
- class BaseApiService {
15605
+ class BaseApiService extends BaseService {
15600
15606
  constructor(sdk, auth) {
15601
- __publicField(this, "client");
15607
+ super(sdk);
15602
15608
  __publicField(this, "auth");
15603
- CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
15604
- this.client = sdk;
15605
15609
  this.auth = auth;
15606
15610
  }
15607
- async enqueueRequest(requestDetails) {
15608
- return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
15609
- }
15610
- dispatch(action) {
15611
- this.client.store.dispatch(action);
15612
- }
15613
15611
  }
15614
15612
  class CategoryService extends BaseApiService {
15615
15613
  add(category, workspaceId) {