http-request-manager 18.13.24 → 18.13.25

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.
@@ -926,9 +926,13 @@ class QueryParamsTrackerService {
926
926
  return false;
927
927
  this.cleanupExpiredEntries();
928
928
  if (!normalized.hasQuery) {
929
- this.ensurePathState(normalized.pathKey);
930
- this.persistState();
931
- return true;
929
+ const pathState = this.ensurePathState(normalized.pathKey);
930
+ const pathSeenBefore = !!pathState.baselineQuery;
931
+ if (!pathSeenBefore) {
932
+ pathState.baselineQuery = {};
933
+ this.persistState();
934
+ }
935
+ return !pathSeenBefore;
932
936
  }
933
937
  if (options.mode === 'exact') {
934
938
  return this.checkExact(normalized, options);
@@ -952,7 +956,7 @@ class QueryParamsTrackerService {
952
956
  this.persistState();
953
957
  return true;
954
958
  }
955
- return this.stringifyQuery(pathState.baselineQuery) === this.stringifyQuery(filteredQuery);
959
+ return this.stringifyQuery(pathState.baselineQuery) !== this.stringifyQuery(filteredQuery);
956
960
  }
957
961
  checkVariation(normalized, options) {
958
962
  const pathState = this.ensurePathState(normalized.pathKey);
@@ -7052,12 +7056,9 @@ class HTTPManagerStateService extends ComponentStore {
7052
7056
  }));
7053
7057
  }
7054
7058
  return this.localStorageManagerService.store$(this.databaseOptions.table).pipe(take(1), switchMap((storeData) => {
7055
- const forceRefresh = !!options?.forceRefresh;
7056
7059
  const storedSchemaSignature = this.getStoredSchemaSignature(storeData);
7057
7060
  const expires = storeData?.expires || 0;
7058
7061
  const hasExpired = expires > 0 && this.utils.hasExpired(expires);
7059
- if (forceRefresh)
7060
- return fetchFromAPI();
7061
7062
  if (hasExpired) {
7062
7063
  return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(switchMap(() => fetchFromAPI()), tap(() => {
7063
7064
  this.localStorageManagerService.updateStore({
@@ -7080,15 +7081,8 @@ class HTTPManagerStateService extends ComponentStore {
7080
7081
  this.setData$(dbData);
7081
7082
  return of(dbData);
7082
7083
  }
7083
- const currentStateData = this.get()?.data;
7084
- if (Array.isArray(currentStateData) && currentStateData.length > 0)
7085
- return of(currentStateData);
7086
- if (currentStateData &&
7087
- !Array.isArray(currentStateData) &&
7088
- Object.keys(currentStateData).length > 0) {
7089
- return of(currentStateData);
7090
- }
7091
- return of(this.dataType === DataType.ARRAY ? [] : {});
7084
+ // DB empty → fall back to API
7085
+ return fetchFromAPI();
7092
7086
  }), catchError((error) => {
7093
7087
  const tableName = this.databaseOptions.table;
7094
7088
  console.warn('[DB STORAGE] getTableRecords failed, recreating table and falling back to API:', { table: tableName, error });
@@ -7246,13 +7240,8 @@ class HTTPManagerStateService extends ComponentStore {
7246
7240
  if (this.hasDatabase && this.databaseOptions?.table) {
7247
7241
  const requestSignature = this.buildRequestSignature('STREAM', requestOptions, effectiveParams);
7248
7242
  return this.localStorageManagerService.store$(this.databaseOptions.table).pipe(take(1), switchMap((storeData) => {
7249
- const forceRefresh = !!options?.forceRefresh;
7250
7243
  const expires = storeData?.expires || 0;
7251
7244
  const hasExpired = expires > 0 && this.utils.hasExpired(expires);
7252
- if (forceRefresh) {
7253
- this.setCachedRequestSignature(this.databaseOptions.table, 'STREAM', requestSignature);
7254
- return this.httpManagerService.getRequest(requestOptions, effectiveParams).pipe(map((apiData) => ({ data: apiData, fromCache: false })));
7255
- }
7256
7245
  if (hasExpired) {
7257
7246
  return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(tap(() => this.setCachedRequestSignature(this.databaseOptions.table, 'STREAM', requestSignature)), switchMap(() => this.httpManagerService.getRequest(requestOptions, effectiveParams)), map((apiData) => ({ data: apiData, fromCache: false })));
7258
7247
  }
@@ -7263,16 +7252,8 @@ class HTTPManagerStateService extends ComponentStore {
7263
7252
  if (Array.isArray(dbData) && dbData.length > 0) {
7264
7253
  return of({ data: dbData, fromCache: true });
7265
7254
  }
7266
- const currentStateData = this.get()?.data;
7267
- if (Array.isArray(currentStateData) && currentStateData.length > 0) {
7268
- return of({ data: currentStateData, fromCache: true });
7269
- }
7270
- if (currentStateData &&
7271
- !Array.isArray(currentStateData) &&
7272
- Object.keys(currentStateData).length > 0) {
7273
- return of({ data: currentStateData, fromCache: true });
7274
- }
7275
- return of({ data: this.dataType === DataType.ARRAY ? [] : {}, fromCache: true });
7255
+ // DB empty → fall back to API
7256
+ return this.httpManagerService.getRequest(requestOptions, effectiveParams).pipe(map((apiData) => ({ data: apiData, fromCache: false })));
7276
7257
  }));
7277
7258
  }
7278
7259
  this.setCachedRequestSignature(this.databaseOptions.table, 'STREAM', requestSignature);