http-request-manager 18.13.19 → 18.13.22

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.
@@ -6150,7 +6150,10 @@ class DbService extends Dexie {
6150
6150
  }
6151
6151
  }
6152
6152
  async createNewDatabase() {
6153
- return this.dbReady;
6153
+ if (this.isOpen()) {
6154
+ this.close();
6155
+ }
6156
+ await this.open();
6154
6157
  }
6155
6158
  get vr() {
6156
6159
  return this.verno;
@@ -7008,6 +7011,7 @@ class HTTPManagerStateService extends ComponentStore {
7008
7011
  databaseOptions: this.databaseOptions
7009
7012
  });
7010
7013
  if (this.hasDatabase && this.databaseOptions?.table) {
7014
+ console.log('[DB STORAGE] Stage 1');
7011
7015
  return this.dbManagerService.databaseExists().pipe(switchMap((dbExists) => {
7012
7016
  if (!dbExists) {
7013
7017
  const initObs = this.initDBStorageAsync();
@@ -7016,6 +7020,7 @@ class HTTPManagerStateService extends ComponentStore {
7016
7020
  return fetchFromAPI();
7017
7021
  }));
7018
7022
  }
7023
+ console.log('[DB STORAGE] Stage 2');
7019
7024
  return this.dbManagerService.hasDatabaseTable(this.databaseOptions.table).pipe(switchMap((tableExists) => {
7020
7025
  if (!tableExists) {
7021
7026
  const initObs = this.initDBStorageAsync();
@@ -7024,14 +7029,14 @@ class HTTPManagerStateService extends ComponentStore {
7024
7029
  return fetchFromAPI();
7025
7030
  }));
7026
7031
  }
7032
+ console.log('[DB STORAGE] Stage 3');
7027
7033
  return this.localStorageManagerService.store$(this.databaseOptions.table).pipe(take(1), switchMap((storeData) => {
7028
7034
  const forceRefresh = !!options?.forceRefresh;
7029
7035
  const storedSchemaSignature = this.getStoredSchemaSignature(storeData);
7030
7036
  const expires = storeData?.expires || 0;
7031
7037
  const hasExpired = expires > 0 && this.utils.hasExpired(expires);
7032
- if (forceRefresh) {
7038
+ if (forceRefresh)
7033
7039
  return fetchFromAPI();
7034
- }
7035
7040
  if (hasExpired) {
7036
7041
  return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(switchMap(() => fetchFromAPI()), tap(() => {
7037
7042
  this.localStorageManagerService.updateStore({
@@ -7040,26 +7045,29 @@ class HTTPManagerStateService extends ComponentStore {
7040
7045
  });
7041
7046
  }));
7042
7047
  }
7048
+ console.log('[DB STORAGE] Stage 4');
7043
7049
  const expectedSchema = this.buildSchemaFromAdapter();
7044
7050
  const expectedSchemaSignature = this.buildSchemaSignature(expectedSchema);
7045
7051
  if (storedSchemaSignature && storedSchemaSignature !== expectedSchemaSignature) {
7046
7052
  const tableDef = TableSchemaDef.adapt({ table: this.databaseOptions.table, schema: expectedSchema });
7047
7053
  return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(switchMap(() => this.dbManagerService.createDatabaseTable(tableDef)), switchMap(() => fetchFromAPI()));
7048
7054
  }
7049
- const trackerAllowsRequest = this.queryParamsTrackerService.checkRequestOptions(this.resolvePath(effectiveParams), this.buildQueryTrackerOptions(options));
7050
- const shouldMakeRequest = trackerAllowsRequest;
7051
- if (shouldMakeRequest) {
7055
+ const shouldMakeRequest = this.queryParamsTrackerService.checkRequestOptions(this.resolvePath(effectiveParams), this.buildQueryTrackerOptions(options));
7056
+ console.log('[DB CHECK] Request options check:', {
7057
+ shouldMakeRequest,
7058
+ effectiveParams,
7059
+ options
7060
+ });
7061
+ if (shouldMakeRequest)
7052
7062
  return fetchFromAPI();
7053
- }
7054
7063
  return this.dbManagerService.getTableRecords(this.databaseOptions.table).pipe(switchMap((dbData) => {
7055
7064
  if (Array.isArray(dbData) && dbData.length > 0) {
7056
7065
  this.setData$(dbData);
7057
7066
  return of(dbData);
7058
7067
  }
7059
7068
  const currentStateData = this.get()?.data;
7060
- if (Array.isArray(currentStateData) && currentStateData.length > 0) {
7069
+ if (Array.isArray(currentStateData) && currentStateData.length > 0)
7061
7070
  return of(currentStateData);
7062
- }
7063
7071
  if (currentStateData &&
7064
7072
  !Array.isArray(currentStateData) &&
7065
7073
  Object.keys(currentStateData).length > 0) {