http-request-manager 18.13.24 → 18.13.26
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
|
-
|
|
931
|
-
|
|
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)
|
|
959
|
+
return this.stringifyQuery(pathState.baselineQuery) !== this.stringifyQuery(filteredQuery);
|
|
956
960
|
}
|
|
957
961
|
checkVariation(normalized, options) {
|
|
958
962
|
const pathState = this.ensurePathState(normalized.pathKey);
|
|
@@ -1161,20 +1165,20 @@ class QueryParamsTrackerService {
|
|
|
1161
1165
|
return;
|
|
1162
1166
|
}
|
|
1163
1167
|
this.stateRestored = true;
|
|
1164
|
-
this.initializeTrackingForSession();
|
|
1168
|
+
// this.initializeTrackingForSession();
|
|
1165
1169
|
this.restoreState();
|
|
1166
1170
|
}
|
|
1167
|
-
initializeTrackingForSession() {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
}
|
|
1171
|
+
// private initializeTrackingForSession(): void {
|
|
1172
|
+
// if (!this.hasSessionStorage()) {
|
|
1173
|
+
// return;
|
|
1174
|
+
// }
|
|
1175
|
+
// const initialized = sessionStorage.getItem(TRACKER_SESSION_INIT_KEY);
|
|
1176
|
+
// if (initialized === '1') {
|
|
1177
|
+
// return;
|
|
1178
|
+
// }
|
|
1179
|
+
// this.clearTracking();
|
|
1180
|
+
// sessionStorage.setItem(TRACKER_SESSION_INIT_KEY, '1');
|
|
1181
|
+
// }
|
|
1178
1182
|
restoreState() {
|
|
1179
1183
|
this.localStorageManager.store$(TRACKER_STORE_NAME)
|
|
1180
1184
|
.pipe(take(1))
|
|
@@ -7056,8 +7060,9 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7056
7060
|
const storedSchemaSignature = this.getStoredSchemaSignature(storeData);
|
|
7057
7061
|
const expires = storeData?.expires || 0;
|
|
7058
7062
|
const hasExpired = expires > 0 && this.utils.hasExpired(expires);
|
|
7059
|
-
if (forceRefresh)
|
|
7063
|
+
if (forceRefresh) {
|
|
7060
7064
|
return fetchFromAPI();
|
|
7065
|
+
}
|
|
7061
7066
|
if (hasExpired) {
|
|
7062
7067
|
return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(switchMap(() => fetchFromAPI()), tap(() => {
|
|
7063
7068
|
this.localStorageManagerService.updateStore({
|
|
@@ -7072,17 +7077,20 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7072
7077
|
const tableDef = TableSchemaDef.adapt({ table: this.databaseOptions.table, schema: expectedSchema });
|
|
7073
7078
|
return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(switchMap(() => this.dbManagerService.createDatabaseTable(tableDef)), switchMap(() => fetchFromAPI()));
|
|
7074
7079
|
}
|
|
7075
|
-
const
|
|
7076
|
-
|
|
7080
|
+
const trackerAllowsRequest = this.queryParamsTrackerService.checkRequestOptions(this.resolvePath(effectiveParams), this.buildQueryTrackerOptions(options));
|
|
7081
|
+
const shouldMakeRequest = trackerAllowsRequest;
|
|
7082
|
+
if (shouldMakeRequest) {
|
|
7077
7083
|
return fetchFromAPI();
|
|
7084
|
+
}
|
|
7078
7085
|
return this.dbManagerService.getTableRecords(this.databaseOptions.table).pipe(switchMap((dbData) => {
|
|
7079
7086
|
if (Array.isArray(dbData) && dbData.length > 0) {
|
|
7080
7087
|
this.setData$(dbData);
|
|
7081
7088
|
return of(dbData);
|
|
7082
7089
|
}
|
|
7083
7090
|
const currentStateData = this.get()?.data;
|
|
7084
|
-
if (Array.isArray(currentStateData) && currentStateData.length > 0)
|
|
7091
|
+
if (Array.isArray(currentStateData) && currentStateData.length > 0) {
|
|
7085
7092
|
return of(currentStateData);
|
|
7093
|
+
}
|
|
7086
7094
|
if (currentStateData &&
|
|
7087
7095
|
!Array.isArray(currentStateData) &&
|
|
7088
7096
|
Object.keys(currentStateData).length > 0) {
|
|
@@ -7422,24 +7430,17 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7422
7430
|
});
|
|
7423
7431
|
}
|
|
7424
7432
|
}
|
|
7425
|
-
|
|
7426
|
-
if (!wsOptions) {
|
|
7427
|
-
this.logger.debug('StateStore', 'WSOptions not provided; skipping WebSocket initialization');
|
|
7428
|
-
return;
|
|
7429
|
-
}
|
|
7430
|
-
const wsId = String(wsOptions.id || '').trim();
|
|
7431
|
-
if (wsId !== '') {
|
|
7432
|
-
wsOptions.id = wsId;
|
|
7433
|
+
if (this.apiOptions.ws && this.apiOptions.ws.id !== '') {
|
|
7433
7434
|
// Auto-prefix channel ID for private state manager channels
|
|
7434
7435
|
// This ensures state manager channels are separate from user-defined channels
|
|
7435
|
-
|
|
7436
|
-
this.logger.debug('StateStore', `🔒 Private state channel configured`, { channelId:
|
|
7436
|
+
this.apiOptions.ws.id = this.prefixChannel(this.apiOptions.ws.id, ChannelType.STATE);
|
|
7437
|
+
this.logger.debug('StateStore', `🔒 Private state channel configured`, { channelId: this.apiOptions.ws.id });
|
|
7437
7438
|
// Store our own sessionId for filtering incoming messages
|
|
7438
7439
|
this.ownSessionId = sessionStorage.getItem('WSID') || null;
|
|
7439
7440
|
this.logger.debug('StateStore', `🆔 Stored own sessionId for message filtering`, { sessionId: this.ownSessionId });
|
|
7440
7441
|
this.logger.debug('StateStore', `🔍 WebSocket configuration`, {
|
|
7441
|
-
channelId:
|
|
7442
|
-
wsServer:
|
|
7442
|
+
channelId: this.apiOptions.ws.id,
|
|
7443
|
+
wsServer: this.apiOptions.ws.wsServer,
|
|
7443
7444
|
sessionId: this.ownSessionId,
|
|
7444
7445
|
path: this.apiOptions.path
|
|
7445
7446
|
});
|
|
@@ -7451,15 +7452,13 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7451
7452
|
// initWS is an effect that triggers when setApiRequestOptions is called with ws config
|
|
7452
7453
|
// The effect is already triggered by calling setApiRequestOptions above
|
|
7453
7454
|
}
|
|
7454
|
-
if (
|
|
7455
|
-
this.maxRetries =
|
|
7456
|
-
this.retryDelay = (
|
|
7455
|
+
if (this.apiOptions.ws?.retry) {
|
|
7456
|
+
this.maxRetries = this.apiOptions.ws.retry.times || 3;
|
|
7457
|
+
this.retryDelay = (this.apiOptions.ws.retry.delay && this.apiOptions.ws.retry.delay * 1000) || 5 * 1000;
|
|
7457
7458
|
this.wsNextRetry.next(this.retryDelay);
|
|
7458
7459
|
}
|
|
7459
7460
|
// Validate wsServer before attempting connection
|
|
7460
|
-
|
|
7461
|
-
wsOptions.wsServer = wsServer;
|
|
7462
|
-
if (!wsServer) {
|
|
7461
|
+
if (!this.apiOptions.ws.wsServer || this.apiOptions.ws.wsServer === '') {
|
|
7463
7462
|
this.logger.error('StateStore', 'WSOptions invalid: wsServer is missing or empty');
|
|
7464
7463
|
return;
|
|
7465
7464
|
}
|
|
@@ -7472,9 +7471,9 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7472
7471
|
this.connectionStatusSubscription = this.setupConnectionStatus().subscribe();
|
|
7473
7472
|
// Make initial connection attempt
|
|
7474
7473
|
this.logger.debug('StateStore', '🔄 Initial WebSocket connection attempt...');
|
|
7475
|
-
this.httpManagerService.connect(
|
|
7474
|
+
this.httpManagerService.connect(this.apiOptions.ws, this.apiOptions.ws.jwtToken || '');
|
|
7476
7475
|
// Initialize WS effect to handle messages
|
|
7477
|
-
this.initWS(
|
|
7476
|
+
this.initWS(this.apiOptions.ws);
|
|
7478
7477
|
}
|
|
7479
7478
|
else {
|
|
7480
7479
|
this.logger.warn('StateStore', 'WSOptions invalid Id: empty');
|
|
@@ -7986,13 +7985,10 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7986
7985
|
return options;
|
|
7987
7986
|
}
|
|
7988
7987
|
buildQueryTrackerOptions(options) {
|
|
7989
|
-
|
|
7988
|
+
return {
|
|
7989
|
+
watchParams: Array.isArray(options?.watchParams) ? options.watchParams : [],
|
|
7990
7990
|
watchExpiresAt: options?.watchExpiresAt,
|
|
7991
7991
|
};
|
|
7992
|
-
if (Array.isArray(options?.watchParams)) {
|
|
7993
|
-
result.watchParams = options.watchParams;
|
|
7994
|
-
}
|
|
7995
|
-
return result;
|
|
7996
7992
|
}
|
|
7997
7993
|
normalizeObject(value) {
|
|
7998
7994
|
if (Array.isArray(value)) {
|