http-request-manager 18.13.18 → 18.13.19
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.
|
@@ -6377,7 +6377,15 @@ class DatabaseManagerService extends DbService {
|
|
|
6377
6377
|
}
|
|
6378
6378
|
createTableRecords(table, records) {
|
|
6379
6379
|
const tableName = this.cleanTableName(table);
|
|
6380
|
-
|
|
6380
|
+
// Keep full object payload; Dexie stores non-indexed properties as well.
|
|
6381
|
+
const insertRecords = records.map((record) => {
|
|
6382
|
+
const payload = { ...(record || {}) };
|
|
6383
|
+
if (payload.id === undefined || payload.id === null || payload.id === '') {
|
|
6384
|
+
delete payload.id;
|
|
6385
|
+
}
|
|
6386
|
+
return payload;
|
|
6387
|
+
});
|
|
6388
|
+
const writeRecords = () => from(this.DBOpened()).pipe(switchMap((opened) => {
|
|
6381
6389
|
if (!opened) {
|
|
6382
6390
|
console.error(`createTableRecords: DB not open. Cannot write to '${tableName}'.`);
|
|
6383
6391
|
return EMPTY;
|
|
@@ -6387,17 +6395,28 @@ class DatabaseManagerService extends DbService {
|
|
|
6387
6395
|
return EMPTY;
|
|
6388
6396
|
}
|
|
6389
6397
|
const tableInstance = this.table(tableName);
|
|
6390
|
-
// Keep full object payload; Dexie stores non-indexed properties as well.
|
|
6391
|
-
const insertRecords = records.map((record) => {
|
|
6392
|
-
const payload = { ...(record || {}) };
|
|
6393
|
-
if (payload.id === undefined || payload.id === null || payload.id === '') {
|
|
6394
|
-
delete payload.id;
|
|
6395
|
-
}
|
|
6396
|
-
return payload;
|
|
6397
|
-
});
|
|
6398
6398
|
console.log(`createTableRecords: Bulk putting ${insertRecords.length} records into ${tableName}`);
|
|
6399
6399
|
return from(tableInstance.bulkPut(insertRecords)).pipe(map(() => insertRecords));
|
|
6400
6400
|
}));
|
|
6401
|
+
return writeRecords().pipe(catchError((error) => {
|
|
6402
|
+
if (!this.isMissingObjectStoreError(error)) {
|
|
6403
|
+
throw error;
|
|
6404
|
+
}
|
|
6405
|
+
console.warn(`createTableRecords: Missing object store for '${tableName}'. Waiting for DB readiness and retrying once...`, error);
|
|
6406
|
+
return from(this.createNewDatabase()).pipe(switchMap(() => writeRecords()), catchError((retryError) => {
|
|
6407
|
+
console.error(`createTableRecords: Retry failed for '${tableName}'`, retryError);
|
|
6408
|
+
throw retryError;
|
|
6409
|
+
}));
|
|
6410
|
+
}));
|
|
6411
|
+
}
|
|
6412
|
+
isMissingObjectStoreError(error) {
|
|
6413
|
+
const name = String(error?.name || '').toLowerCase();
|
|
6414
|
+
const innerName = String(error?.inner?.name || '').toLowerCase();
|
|
6415
|
+
const message = String(error?.message || error?.inner?.message || '').toLowerCase();
|
|
6416
|
+
return (name.includes('notfounderror') ||
|
|
6417
|
+
innerName.includes('notfounderror') ||
|
|
6418
|
+
message.includes('object store') ||
|
|
6419
|
+
message.includes('one of the specified object stores was not found'));
|
|
6401
6420
|
}
|
|
6402
6421
|
updateTableRecord(table, record) {
|
|
6403
6422
|
const tableName = this.cleanTableName(table);
|
|
@@ -7380,17 +7399,24 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7380
7399
|
});
|
|
7381
7400
|
}
|
|
7382
7401
|
}
|
|
7383
|
-
|
|
7402
|
+
const wsOptions = this.apiOptions.ws;
|
|
7403
|
+
if (!wsOptions) {
|
|
7404
|
+
this.logger.debug('StateStore', 'WSOptions not provided; skipping WebSocket initialization');
|
|
7405
|
+
return;
|
|
7406
|
+
}
|
|
7407
|
+
const wsId = String(wsOptions.id || '').trim();
|
|
7408
|
+
if (wsId !== '') {
|
|
7409
|
+
wsOptions.id = wsId;
|
|
7384
7410
|
// Auto-prefix channel ID for private state manager channels
|
|
7385
7411
|
// This ensures state manager channels are separate from user-defined channels
|
|
7386
|
-
|
|
7387
|
-
this.logger.debug('StateStore', `🔒 Private state channel configured`, { channelId:
|
|
7412
|
+
wsOptions.id = this.prefixChannel(wsOptions.id, ChannelType.STATE);
|
|
7413
|
+
this.logger.debug('StateStore', `🔒 Private state channel configured`, { channelId: wsOptions.id });
|
|
7388
7414
|
// Store our own sessionId for filtering incoming messages
|
|
7389
7415
|
this.ownSessionId = sessionStorage.getItem('WSID') || null;
|
|
7390
7416
|
this.logger.debug('StateStore', `🆔 Stored own sessionId for message filtering`, { sessionId: this.ownSessionId });
|
|
7391
7417
|
this.logger.debug('StateStore', `🔍 WebSocket configuration`, {
|
|
7392
|
-
channelId:
|
|
7393
|
-
wsServer:
|
|
7418
|
+
channelId: wsOptions.id,
|
|
7419
|
+
wsServer: wsOptions.wsServer,
|
|
7394
7420
|
sessionId: this.ownSessionId,
|
|
7395
7421
|
path: this.apiOptions.path
|
|
7396
7422
|
});
|
|
@@ -7402,13 +7428,15 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7402
7428
|
// initWS is an effect that triggers when setApiRequestOptions is called with ws config
|
|
7403
7429
|
// The effect is already triggered by calling setApiRequestOptions above
|
|
7404
7430
|
}
|
|
7405
|
-
if (
|
|
7406
|
-
this.maxRetries =
|
|
7407
|
-
this.retryDelay = (
|
|
7431
|
+
if (wsOptions.retry) {
|
|
7432
|
+
this.maxRetries = wsOptions.retry.times || 3;
|
|
7433
|
+
this.retryDelay = (wsOptions.retry.delay && wsOptions.retry.delay * 1000) || 5 * 1000;
|
|
7408
7434
|
this.wsNextRetry.next(this.retryDelay);
|
|
7409
7435
|
}
|
|
7410
7436
|
// Validate wsServer before attempting connection
|
|
7411
|
-
|
|
7437
|
+
const wsServer = String(wsOptions.wsServer || '').trim();
|
|
7438
|
+
wsOptions.wsServer = wsServer;
|
|
7439
|
+
if (!wsServer) {
|
|
7412
7440
|
this.logger.error('StateStore', 'WSOptions invalid: wsServer is missing or empty');
|
|
7413
7441
|
return;
|
|
7414
7442
|
}
|
|
@@ -7421,9 +7449,9 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7421
7449
|
this.connectionStatusSubscription = this.setupConnectionStatus().subscribe();
|
|
7422
7450
|
// Make initial connection attempt
|
|
7423
7451
|
this.logger.debug('StateStore', '🔄 Initial WebSocket connection attempt...');
|
|
7424
|
-
this.httpManagerService.connect(
|
|
7452
|
+
this.httpManagerService.connect(wsOptions, wsOptions.jwtToken || '');
|
|
7425
7453
|
// Initialize WS effect to handle messages
|
|
7426
|
-
this.initWS(
|
|
7454
|
+
this.initWS(wsOptions);
|
|
7427
7455
|
}
|
|
7428
7456
|
else {
|
|
7429
7457
|
this.logger.warn('StateStore', 'WSOptions invalid Id: empty');
|