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