http-request-manager 18.15.21 → 18.15.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.
|
@@ -978,14 +978,19 @@ class StreamingProcessor {
|
|
|
978
978
|
// Only return NEW items since last parse (progressive updates)
|
|
979
979
|
const newItems = parsedData.slice(this.lastParsedLength);
|
|
980
980
|
this.lastParsedLength = parsedData.length;
|
|
981
|
-
// Calculate progress
|
|
981
|
+
// Calculate progress — prefer record count from header, fall back to byte-level
|
|
982
|
+
const total = this.totalFromHeader ?? event.total;
|
|
983
|
+
const received = this.totalFromHeader ? this.lastParsedLength : event.loaded;
|
|
984
|
+
const percent = total
|
|
985
|
+
? Math.round((received / total) * 100)
|
|
986
|
+
: 0;
|
|
982
987
|
const progress = {
|
|
983
|
-
received
|
|
984
|
-
total
|
|
985
|
-
percent
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
988
|
+
received,
|
|
989
|
+
total,
|
|
990
|
+
percent,
|
|
991
|
+
stage: 'streaming',
|
|
992
|
+
bytesLoaded: event.loaded,
|
|
993
|
+
bytesTotal: event.total
|
|
989
994
|
};
|
|
990
995
|
return {
|
|
991
996
|
data: newItems.length > 0 ? newItems : [],
|
|
@@ -997,14 +1002,16 @@ class StreamingProcessor {
|
|
|
997
1002
|
if (event.body) {
|
|
998
1003
|
this.buffer = typeof event.body === 'string' ? event.body : this.buffer;
|
|
999
1004
|
const parsedData = this.parseBuffer();
|
|
1000
|
-
// Calculate final progress
|
|
1005
|
+
// Calculate final progress — prefer record count from header, fall back to byte-level
|
|
1006
|
+
const total = this.totalFromHeader ?? event.total;
|
|
1007
|
+
const received = this.totalFromHeader ? parsedData.length : event.loaded;
|
|
1001
1008
|
const progress = {
|
|
1002
|
-
received
|
|
1003
|
-
total
|
|
1004
|
-
percent:
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1009
|
+
received,
|
|
1010
|
+
total,
|
|
1011
|
+
percent: 100,
|
|
1012
|
+
stage: 'complete',
|
|
1013
|
+
bytesLoaded: event.loaded,
|
|
1014
|
+
bytesTotal: event.total
|
|
1008
1015
|
};
|
|
1009
1016
|
return {
|
|
1010
1017
|
data: parsedData.length > 0 ? parsedData : [],
|
|
@@ -7302,11 +7309,11 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7302
7309
|
}
|
|
7303
7310
|
}));
|
|
7304
7311
|
};
|
|
7305
|
-
console.log('[DB STORAGE] Checking database storage:', {
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
})
|
|
7312
|
+
// console.log('[DB STORAGE] Checking database storage:', {
|
|
7313
|
+
// hasDatabase: this.hasDatabase,
|
|
7314
|
+
// table: this.databaseOptions?.table,
|
|
7315
|
+
// databaseOptions: this.databaseOptions
|
|
7316
|
+
// })
|
|
7310
7317
|
if (this.hasDatabase && this.databaseOptions?.table) {
|
|
7311
7318
|
return this.dbManagerService.databaseExists().pipe(switchMap((dbExists) => {
|
|
7312
7319
|
if (!dbExists) {
|
|
@@ -7600,7 +7607,7 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7600
7607
|
const res = packet?.data;
|
|
7601
7608
|
// console.log('[DEBUG] Streaming response received:', res)
|
|
7602
7609
|
if (res && res.length > 0) {
|
|
7603
|
-
console.log('[DEBUG] Updating state with streaming data:', res)
|
|
7610
|
+
// console.log('[DEBUG] Updating state with streaming data:', res)
|
|
7604
7611
|
this.setData$(res);
|
|
7605
7612
|
this.streamedResponse = [...this.streamedResponse, ...res];
|
|
7606
7613
|
}
|
|
@@ -7610,7 +7617,7 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7610
7617
|
}
|
|
7611
7618
|
return this.persistStreamDataToDb(packet?.data, options);
|
|
7612
7619
|
}), map((res) => {
|
|
7613
|
-
console.log('[DEBUG] Returning data to subscribers:', res)
|
|
7620
|
+
// console.log('[DEBUG] Returning data to subscribers:', res)
|
|
7614
7621
|
return res;
|
|
7615
7622
|
}), catchError((error) => {
|
|
7616
7623
|
console.error('[DEBUG] Streaming error:', error);
|
|
@@ -7623,15 +7630,15 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7623
7630
|
console.log('[DEBUG] Streaming response received:', res);
|
|
7624
7631
|
// Always update state with streaming data
|
|
7625
7632
|
if (res && res.length > 0) {
|
|
7626
|
-
console.log('[DEBUG] Updating state with streaming data:', res)
|
|
7633
|
+
// console.log('[DEBUG] Updating state with streaming data:', res)
|
|
7627
7634
|
this.setData$(res);
|
|
7628
7635
|
this.streamedResponse = [...this.streamedResponse, ...res];
|
|
7629
7636
|
}
|
|
7630
7637
|
else {
|
|
7631
|
-
console.log('[DEBUG] No streaming data or empty array:', res)
|
|
7638
|
+
// console.log('[DEBUG] No streaming data or empty array:', res)
|
|
7632
7639
|
}
|
|
7633
7640
|
}), concatMap((res) => this.persistStreamDataToDb(res, options)), map((res) => {
|
|
7634
|
-
console.log('[DEBUG] Returning data to subscribers:', res)
|
|
7641
|
+
// console.log('[DEBUG] Returning data to subscribers:', res)
|
|
7635
7642
|
return res; // Return the data so subscribers can receive it
|
|
7636
7643
|
}), catchError((error) => {
|
|
7637
7644
|
// console.error('[DEBUG] Streaming error:', error)
|