http-request-manager 18.13.20 → 18.13.23
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.
|
@@ -6393,11 +6393,11 @@ class DatabaseManagerService extends DbService {
|
|
|
6393
6393
|
console.error(`createTableRecords: DB not open. Cannot write to '${tableName}'.`);
|
|
6394
6394
|
return EMPTY;
|
|
6395
6395
|
}
|
|
6396
|
-
|
|
6396
|
+
const tableInstance = this.tables.find(t => t.name === tableName);
|
|
6397
|
+
if (!tableInstance) {
|
|
6397
6398
|
console.error(`createTableRecords: Table '${tableName}' does not exist in DB version ${this.verno}. Available:`, this.tables.map(t => t.name));
|
|
6398
6399
|
return EMPTY;
|
|
6399
6400
|
}
|
|
6400
|
-
const tableInstance = this.table(tableName);
|
|
6401
6401
|
console.log(`createTableRecords: Bulk putting ${insertRecords.length} records into ${tableName}`);
|
|
6402
6402
|
return from(tableInstance.bulkPut(insertRecords)).pipe(map(() => insertRecords));
|
|
6403
6403
|
}));
|
|
@@ -7011,6 +7011,7 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7011
7011
|
databaseOptions: this.databaseOptions
|
|
7012
7012
|
});
|
|
7013
7013
|
if (this.hasDatabase && this.databaseOptions?.table) {
|
|
7014
|
+
console.log('[DB STORAGE] Stage 1');
|
|
7014
7015
|
return this.dbManagerService.databaseExists().pipe(switchMap((dbExists) => {
|
|
7015
7016
|
if (!dbExists) {
|
|
7016
7017
|
const initObs = this.initDBStorageAsync();
|
|
@@ -7019,6 +7020,7 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7019
7020
|
return fetchFromAPI();
|
|
7020
7021
|
}));
|
|
7021
7022
|
}
|
|
7023
|
+
console.log('[DB STORAGE] Stage 2');
|
|
7022
7024
|
return this.dbManagerService.hasDatabaseTable(this.databaseOptions.table).pipe(switchMap((tableExists) => {
|
|
7023
7025
|
if (!tableExists) {
|
|
7024
7026
|
const initObs = this.initDBStorageAsync();
|
|
@@ -7027,14 +7029,14 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7027
7029
|
return fetchFromAPI();
|
|
7028
7030
|
}));
|
|
7029
7031
|
}
|
|
7032
|
+
console.log('[DB STORAGE] Stage 3');
|
|
7030
7033
|
return this.localStorageManagerService.store$(this.databaseOptions.table).pipe(take(1), switchMap((storeData) => {
|
|
7031
7034
|
const forceRefresh = !!options?.forceRefresh;
|
|
7032
7035
|
const storedSchemaSignature = this.getStoredSchemaSignature(storeData);
|
|
7033
7036
|
const expires = storeData?.expires || 0;
|
|
7034
7037
|
const hasExpired = expires > 0 && this.utils.hasExpired(expires);
|
|
7035
|
-
if (forceRefresh)
|
|
7038
|
+
if (forceRefresh)
|
|
7036
7039
|
return fetchFromAPI();
|
|
7037
|
-
}
|
|
7038
7040
|
if (hasExpired) {
|
|
7039
7041
|
return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(switchMap(() => fetchFromAPI()), tap(() => {
|
|
7040
7042
|
this.localStorageManagerService.updateStore({
|
|
@@ -7043,26 +7045,29 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7043
7045
|
});
|
|
7044
7046
|
}));
|
|
7045
7047
|
}
|
|
7048
|
+
console.log('[DB STORAGE] Stage 4');
|
|
7046
7049
|
const expectedSchema = this.buildSchemaFromAdapter();
|
|
7047
7050
|
const expectedSchemaSignature = this.buildSchemaSignature(expectedSchema);
|
|
7048
7051
|
if (storedSchemaSignature && storedSchemaSignature !== expectedSchemaSignature) {
|
|
7049
7052
|
const tableDef = TableSchemaDef.adapt({ table: this.databaseOptions.table, schema: expectedSchema });
|
|
7050
7053
|
return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(switchMap(() => this.dbManagerService.createDatabaseTable(tableDef)), switchMap(() => fetchFromAPI()));
|
|
7051
7054
|
}
|
|
7052
|
-
const
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
+
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
|
+
if (shouldMakeRequest)
|
|
7055
7062
|
return fetchFromAPI();
|
|
7056
|
-
}
|
|
7057
7063
|
return this.dbManagerService.getTableRecords(this.databaseOptions.table).pipe(switchMap((dbData) => {
|
|
7058
7064
|
if (Array.isArray(dbData) && dbData.length > 0) {
|
|
7059
7065
|
this.setData$(dbData);
|
|
7060
7066
|
return of(dbData);
|
|
7061
7067
|
}
|
|
7062
7068
|
const currentStateData = this.get()?.data;
|
|
7063
|
-
if (Array.isArray(currentStateData) && currentStateData.length > 0)
|
|
7069
|
+
if (Array.isArray(currentStateData) && currentStateData.length > 0)
|
|
7064
7070
|
return of(currentStateData);
|
|
7065
|
-
}
|
|
7066
7071
|
if (currentStateData &&
|
|
7067
7072
|
!Array.isArray(currentStateData) &&
|
|
7068
7073
|
Object.keys(currentStateData).length > 0) {
|