http-request-manager 18.13.23 → 18.13.24
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.
|
@@ -943,7 +943,7 @@ class QueryParamsTrackerService {
|
|
|
943
943
|
}
|
|
944
944
|
checkExact(normalized, options) {
|
|
945
945
|
const pathState = this.ensurePathState(normalized.pathKey);
|
|
946
|
-
const filteredQuery = normalized.query;
|
|
946
|
+
const filteredQuery = this.filterQueryByWatchParams(normalized.query, options.watchParams);
|
|
947
947
|
if (Object.keys(filteredQuery).length === 0) {
|
|
948
948
|
return false;
|
|
949
949
|
}
|
|
@@ -956,7 +956,16 @@ class QueryParamsTrackerService {
|
|
|
956
956
|
}
|
|
957
957
|
checkVariation(normalized, options) {
|
|
958
958
|
const pathState = this.ensurePathState(normalized.pathKey);
|
|
959
|
-
|
|
959
|
+
if (Array.isArray(options.watchParams) && options.watchParams.length === 0) {
|
|
960
|
+
const pathSeenBefore = !!pathState.baselineQuery;
|
|
961
|
+
if (!pathSeenBefore) {
|
|
962
|
+
pathState.baselineQuery = {};
|
|
963
|
+
pathState.watchExpiresAt = this.buildExpiryEpoch(typeof options.watchExpiresAt !== 'undefined' ? options.watchExpiresAt : options.watchParamsExpire);
|
|
964
|
+
this.persistState();
|
|
965
|
+
}
|
|
966
|
+
return !pathSeenBefore;
|
|
967
|
+
}
|
|
968
|
+
const filteredQuery = this.filterQueryByWatchParams(normalized.query, options.watchParams);
|
|
960
969
|
const keys = Object.keys(filteredQuery);
|
|
961
970
|
if (keys.length === 0) {
|
|
962
971
|
return false;
|
|
@@ -980,6 +989,21 @@ class QueryParamsTrackerService {
|
|
|
980
989
|
}
|
|
981
990
|
return accepted;
|
|
982
991
|
}
|
|
992
|
+
filterQueryByWatchParams(query, watchParams) {
|
|
993
|
+
if (!Array.isArray(watchParams)) {
|
|
994
|
+
return query;
|
|
995
|
+
}
|
|
996
|
+
if (watchParams.length === 0) {
|
|
997
|
+
return {};
|
|
998
|
+
}
|
|
999
|
+
const normalizedWatchParams = watchParams.map((p) => this.normalizeParamKey(p));
|
|
1000
|
+
return Object.keys(query).reduce((acc, key) => {
|
|
1001
|
+
if (normalizedWatchParams.includes(key)) {
|
|
1002
|
+
acc[key] = query[key];
|
|
1003
|
+
}
|
|
1004
|
+
return acc;
|
|
1005
|
+
}, {});
|
|
1006
|
+
}
|
|
983
1007
|
normalizeRequestOptions(requestOptions) {
|
|
984
1008
|
const params = Array.isArray(requestOptions) ? requestOptions : [];
|
|
985
1009
|
const pathSegments = [];
|
|
@@ -1117,7 +1141,7 @@ class QueryParamsTrackerService {
|
|
|
1117
1141
|
pathState.consumedValuesByKey = {};
|
|
1118
1142
|
pathState.watchExpiresAt = undefined;
|
|
1119
1143
|
}
|
|
1120
|
-
const hasBaseline =
|
|
1144
|
+
const hasBaseline = pathState.baselineQuery !== undefined;
|
|
1121
1145
|
const hasTrackedValues = Object.keys(pathState.consumedValuesByKey).some((key) => (pathState.consumedValuesByKey[key] || []).length > 0);
|
|
1122
1146
|
if (!hasBaseline && !hasTrackedValues) {
|
|
1123
1147
|
delete this.state.paths[pathKey];
|
|
@@ -7011,7 +7035,6 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7011
7035
|
databaseOptions: this.databaseOptions
|
|
7012
7036
|
});
|
|
7013
7037
|
if (this.hasDatabase && this.databaseOptions?.table) {
|
|
7014
|
-
console.log('[DB STORAGE] Stage 1');
|
|
7015
7038
|
return this.dbManagerService.databaseExists().pipe(switchMap((dbExists) => {
|
|
7016
7039
|
if (!dbExists) {
|
|
7017
7040
|
const initObs = this.initDBStorageAsync();
|
|
@@ -7020,7 +7043,6 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7020
7043
|
return fetchFromAPI();
|
|
7021
7044
|
}));
|
|
7022
7045
|
}
|
|
7023
|
-
console.log('[DB STORAGE] Stage 2');
|
|
7024
7046
|
return this.dbManagerService.hasDatabaseTable(this.databaseOptions.table).pipe(switchMap((tableExists) => {
|
|
7025
7047
|
if (!tableExists) {
|
|
7026
7048
|
const initObs = this.initDBStorageAsync();
|
|
@@ -7029,7 +7051,6 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7029
7051
|
return fetchFromAPI();
|
|
7030
7052
|
}));
|
|
7031
7053
|
}
|
|
7032
|
-
console.log('[DB STORAGE] Stage 3');
|
|
7033
7054
|
return this.localStorageManagerService.store$(this.databaseOptions.table).pipe(take(1), switchMap((storeData) => {
|
|
7034
7055
|
const forceRefresh = !!options?.forceRefresh;
|
|
7035
7056
|
const storedSchemaSignature = this.getStoredSchemaSignature(storeData);
|
|
@@ -7045,7 +7066,6 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7045
7066
|
});
|
|
7046
7067
|
}));
|
|
7047
7068
|
}
|
|
7048
|
-
console.log('[DB STORAGE] Stage 4');
|
|
7049
7069
|
const expectedSchema = this.buildSchemaFromAdapter();
|
|
7050
7070
|
const expectedSchemaSignature = this.buildSchemaSignature(expectedSchema);
|
|
7051
7071
|
if (storedSchemaSignature && storedSchemaSignature !== expectedSchemaSignature) {
|
|
@@ -7053,11 +7073,6 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7053
7073
|
return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(switchMap(() => this.dbManagerService.createDatabaseTable(tableDef)), switchMap(() => fetchFromAPI()));
|
|
7054
7074
|
}
|
|
7055
7075
|
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
7076
|
if (shouldMakeRequest)
|
|
7062
7077
|
return fetchFromAPI();
|
|
7063
7078
|
return this.dbManagerService.getTableRecords(this.databaseOptions.table).pipe(switchMap((dbData) => {
|
|
@@ -7971,10 +7986,13 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7971
7986
|
return options;
|
|
7972
7987
|
}
|
|
7973
7988
|
buildQueryTrackerOptions(options) {
|
|
7974
|
-
|
|
7975
|
-
watchParams: Array.isArray(options?.watchParams) ? options.watchParams : [],
|
|
7989
|
+
const result = {
|
|
7976
7990
|
watchExpiresAt: options?.watchExpiresAt,
|
|
7977
7991
|
};
|
|
7992
|
+
if (Array.isArray(options?.watchParams)) {
|
|
7993
|
+
result.watchParams = options.watchParams;
|
|
7994
|
+
}
|
|
7995
|
+
return result;
|
|
7978
7996
|
}
|
|
7979
7997
|
normalizeObject(value) {
|
|
7980
7998
|
if (Array.isArray(value)) {
|