http-request-manager 18.15.24 → 18.15.27
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.
|
@@ -942,6 +942,39 @@ class QueryParamsTrackerOptionsModel {
|
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
944
|
|
|
945
|
+
class StreamConfigModel {
|
|
946
|
+
constructor(streamType = StreamType.AI_STREAMING, totalHeader = 'X-Total-Count') {
|
|
947
|
+
this.streamType = streamType;
|
|
948
|
+
this.totalHeader = totalHeader;
|
|
949
|
+
}
|
|
950
|
+
static adapt(item) {
|
|
951
|
+
return new StreamConfigModel(item?.streamType, item?.totalHeader);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
class StreamProgressModel {
|
|
956
|
+
constructor(received = 0, total, percent = 0, stage = 'connecting') {
|
|
957
|
+
this.received = received;
|
|
958
|
+
this.total = total;
|
|
959
|
+
this.percent = percent;
|
|
960
|
+
this.stage = stage;
|
|
961
|
+
}
|
|
962
|
+
static adapt(item) {
|
|
963
|
+
return new StreamProgressModel(item?.received, item?.total, item?.percent, item?.stage);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
class StreamOutputModel {
|
|
968
|
+
constructor(data = [], progress = new StreamProgressModel(), endpoint) {
|
|
969
|
+
this.data = data;
|
|
970
|
+
this.progress = progress;
|
|
971
|
+
this.endpoint = endpoint;
|
|
972
|
+
}
|
|
973
|
+
static adapt(item) {
|
|
974
|
+
return new StreamOutputModel(Array.isArray(item?.data) ? item.data : [], item?.progress ? StreamProgressModel.adapt(item.progress) : new StreamProgressModel(), item?.endpoint);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
945
978
|
/**
|
|
946
979
|
* Stateful processor for managing streaming data and events
|
|
947
980
|
*/
|
|
@@ -951,7 +984,7 @@ class StreamingProcessor {
|
|
|
951
984
|
this.contentType = '';
|
|
952
985
|
this.maxBufferSize = 10 * 1024 * 1024; // 10MB limit
|
|
953
986
|
this.lastParsedLength = 0; // Track parsed position to avoid duplicates
|
|
954
|
-
this.streamConfig = config ||
|
|
987
|
+
this.streamConfig = config || new StreamConfigModel(StreamType.AI_STREAMING);
|
|
955
988
|
}
|
|
956
989
|
/**
|
|
957
990
|
* Process HTTP events and extract streaming data with progress
|
|
@@ -984,35 +1017,33 @@ class StreamingProcessor {
|
|
|
984
1017
|
const percent = total
|
|
985
1018
|
? Math.round((received / total) * 100)
|
|
986
1019
|
: 0;
|
|
987
|
-
const progress = {
|
|
1020
|
+
const progress = StreamProgressModel.adapt({
|
|
988
1021
|
received,
|
|
989
1022
|
total,
|
|
990
1023
|
percent,
|
|
991
1024
|
stage: 'streaming'
|
|
992
|
-
};
|
|
993
|
-
return {
|
|
1025
|
+
});
|
|
1026
|
+
return StreamOutputModel.adapt({
|
|
994
1027
|
data: newItems.length > 0 ? newItems : [],
|
|
995
1028
|
progress
|
|
996
|
-
};
|
|
1029
|
+
});
|
|
997
1030
|
}
|
|
998
1031
|
return null;
|
|
999
1032
|
case HttpEventType.Response:
|
|
1000
1033
|
if (event.body) {
|
|
1001
1034
|
this.buffer = typeof event.body === 'string' ? event.body : this.buffer;
|
|
1002
1035
|
const parsedData = this.parseBuffer();
|
|
1003
|
-
// Calculate final progress
|
|
1004
|
-
const total = this.totalFromHeader ?? event.total;
|
|
1036
|
+
// Calculate final progress
|
|
1005
1037
|
const received = this.totalFromHeader ? parsedData.length : event.loaded;
|
|
1006
|
-
const progress = {
|
|
1038
|
+
const progress = StreamProgressModel.adapt({
|
|
1007
1039
|
received,
|
|
1008
|
-
total,
|
|
1009
1040
|
percent: 100,
|
|
1010
1041
|
stage: 'complete'
|
|
1011
|
-
};
|
|
1012
|
-
return {
|
|
1042
|
+
});
|
|
1043
|
+
return StreamOutputModel.adapt({
|
|
1013
1044
|
data: parsedData.length > 0 ? parsedData : [],
|
|
1014
1045
|
progress
|
|
1015
|
-
};
|
|
1046
|
+
});
|
|
1016
1047
|
}
|
|
1017
1048
|
return null;
|
|
1018
1049
|
default:
|
|
@@ -1320,23 +1351,23 @@ function isNdjsonFormat(buffer) {
|
|
|
1320
1351
|
*/
|
|
1321
1352
|
// Stream with JSON format
|
|
1322
1353
|
function streamJSON() {
|
|
1323
|
-
return requestStreaming({ streamType: StreamType.JSON });
|
|
1354
|
+
return requestStreaming(StreamConfigModel.adapt({ streamType: StreamType.JSON }));
|
|
1324
1355
|
}
|
|
1325
1356
|
// Stream with NDJSON format
|
|
1326
1357
|
function streamNDJSON() {
|
|
1327
|
-
return requestStreaming({ streamType: StreamType.NDJSON });
|
|
1358
|
+
return requestStreaming(StreamConfigModel.adapt({ streamType: StreamType.NDJSON }));
|
|
1328
1359
|
}
|
|
1329
1360
|
// Stream AI responses
|
|
1330
1361
|
function streamAI() {
|
|
1331
|
-
return requestStreaming({ streamType: StreamType.AI_STREAMING });
|
|
1362
|
+
return requestStreaming(StreamConfigModel.adapt({ streamType: StreamType.AI_STREAMING }));
|
|
1332
1363
|
}
|
|
1333
1364
|
// Stream Server-Sent Events
|
|
1334
1365
|
function streamEvents() {
|
|
1335
|
-
return requestStreaming({ streamType: StreamType.EVENT_STREAM });
|
|
1366
|
+
return requestStreaming(StreamConfigModel.adapt({ streamType: StreamType.EVENT_STREAM }));
|
|
1336
1367
|
}
|
|
1337
1368
|
// Auto-detect streaming format
|
|
1338
1369
|
function streamAuto() {
|
|
1339
|
-
return requestStreaming({ streamType: StreamType.AUTO });
|
|
1370
|
+
return requestStreaming(StreamConfigModel.adapt({ streamType: StreamType.AUTO }));
|
|
1340
1371
|
}
|
|
1341
1372
|
|
|
1342
1373
|
class ChannelInfo {
|
|
@@ -2938,12 +2969,12 @@ class RequestService extends WebsocketService {
|
|
|
2938
2969
|
this.isPending$ = this.isPending.asObservable();
|
|
2939
2970
|
this.progress = new BehaviorSubject(0);
|
|
2940
2971
|
this.progress$ = this.progress.asObservable();
|
|
2941
|
-
this.streamProgress = new BehaviorSubject({
|
|
2972
|
+
this.streamProgress = new BehaviorSubject(StreamProgressModel.adapt({
|
|
2942
2973
|
received: 0,
|
|
2943
2974
|
total: undefined,
|
|
2944
2975
|
percent: 0,
|
|
2945
2976
|
stage: 'connecting'
|
|
2946
|
-
});
|
|
2977
|
+
}));
|
|
2947
2978
|
this.streamProgress$ = this.streamProgress.asObservable();
|
|
2948
2979
|
}
|
|
2949
2980
|
// Implementation
|
|
@@ -2959,7 +2990,7 @@ class RequestService extends WebsocketService {
|
|
|
2959
2990
|
reportProgress: true
|
|
2960
2991
|
}).pipe(
|
|
2961
2992
|
// tap(data => console.log('STREAM DATA', data)),
|
|
2962
|
-
requestStreaming({ streamType: options.streamType || StreamType.NDJSON }), this.requestStreaming(options), this.handleFinalize())
|
|
2993
|
+
requestStreaming(StreamConfigModel.adapt({ streamType: options.streamType || StreamType.NDJSON, totalHeader: 'X-Total-Count' })), this.requestStreaming(options), this.handleFinalize())
|
|
2963
2994
|
: this.http.get(urlPath, headers).pipe(this.request(options));
|
|
2964
2995
|
}
|
|
2965
2996
|
createRecordRequest(options, data) {
|
|
@@ -2972,7 +3003,7 @@ class RequestService extends WebsocketService {
|
|
|
2972
3003
|
observe: 'events',
|
|
2973
3004
|
responseType: 'text',
|
|
2974
3005
|
reportProgress: true
|
|
2975
|
-
}).pipe(requestStreaming({ streamType: options.streamType || StreamType.NDJSON }), this.requestStreaming(options), this.handleFinalize())
|
|
3006
|
+
}).pipe(requestStreaming(StreamConfigModel.adapt({ streamType: options.streamType || StreamType.NDJSON, totalHeader: 'X-Total-Count' })), this.requestStreaming(options), this.handleFinalize())
|
|
2976
3007
|
: this.http.post(urlPath, data, headers).pipe(this.request(options));
|
|
2977
3008
|
}
|
|
2978
3009
|
updateRecordRequest(options, data) {
|
|
@@ -4251,7 +4282,7 @@ class RequestSignalsService extends WebsocketService {
|
|
|
4251
4282
|
observe: 'events',
|
|
4252
4283
|
responseType: 'text',
|
|
4253
4284
|
reportProgress: true
|
|
4254
|
-
}).pipe(requestStreaming({ streamType: options.streamType || StreamType.AI_STREAMING }), this.requestStreamingOperator(options), this.handleFinalize())
|
|
4285
|
+
}).pipe(requestStreaming(StreamConfigModel.adapt({ streamType: options.streamType || StreamType.AI_STREAMING })), this.requestStreamingOperator(options), this.handleFinalize())
|
|
4255
4286
|
: this.http.get(urlPath, headers).pipe(this.request(options), this.handleFinalize());
|
|
4256
4287
|
}
|
|
4257
4288
|
// Implementation
|
|
@@ -4265,7 +4296,7 @@ class RequestSignalsService extends WebsocketService {
|
|
|
4265
4296
|
observe: 'events',
|
|
4266
4297
|
responseType: 'text',
|
|
4267
4298
|
reportProgress: true
|
|
4268
|
-
}).pipe(requestStreaming({ streamType: options.streamType || StreamType.AI_STREAMING }), this.requestStreamingOperator(options), this.handleFinalize())
|
|
4299
|
+
}).pipe(requestStreaming(StreamConfigModel.adapt({ streamType: options.streamType || StreamType.AI_STREAMING })), this.requestStreamingOperator(options), this.handleFinalize())
|
|
4269
4300
|
: this.http.post(urlPath, data, headers).pipe(this.request(options), this.handleFinalize());
|
|
4270
4301
|
}
|
|
4271
4302
|
updateRecordRequest(options, data) {
|
|
@@ -5085,6 +5116,39 @@ class OperationResultModel {
|
|
|
5085
5116
|
}
|
|
5086
5117
|
}
|
|
5087
5118
|
|
|
5119
|
+
class StreamEventMetadataModel {
|
|
5120
|
+
constructor(timestamp = new Date(), streamType = StreamType.AI_STREAMING, contentLength) {
|
|
5121
|
+
this.timestamp = timestamp;
|
|
5122
|
+
this.streamType = streamType;
|
|
5123
|
+
this.contentLength = contentLength;
|
|
5124
|
+
}
|
|
5125
|
+
static adapt(item) {
|
|
5126
|
+
return new StreamEventMetadataModel(item?.timestamp, item?.streamType, item?.contentLength);
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
|
|
5130
|
+
class StreamEventModel {
|
|
5131
|
+
constructor(type = 'data', data = null, metadata) {
|
|
5132
|
+
this.type = type;
|
|
5133
|
+
this.data = data;
|
|
5134
|
+
this.metadata = metadata;
|
|
5135
|
+
}
|
|
5136
|
+
static adapt(item) {
|
|
5137
|
+
return new StreamEventModel(item?.type, item?.data, item?.metadata ? StreamEventMetadataModel.adapt(item.metadata) : undefined);
|
|
5138
|
+
}
|
|
5139
|
+
}
|
|
5140
|
+
|
|
5141
|
+
class ParsingResultModel {
|
|
5142
|
+
constructor(success = false, data, error) {
|
|
5143
|
+
this.success = success;
|
|
5144
|
+
this.data = data;
|
|
5145
|
+
this.error = error;
|
|
5146
|
+
}
|
|
5147
|
+
static adapt(item) {
|
|
5148
|
+
return new ParsingResultModel(item?.success, Array.isArray(item?.data) ? item.data : undefined, item?.error);
|
|
5149
|
+
}
|
|
5150
|
+
}
|
|
5151
|
+
|
|
5088
5152
|
class ObjectMergerService {
|
|
5089
5153
|
constructor(configOptions) {
|
|
5090
5154
|
this.configOptions = configOptions;
|
|
@@ -13214,5 +13278,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
13214
13278
|
* Generated bundle index. Do not edit.
|
|
13215
13279
|
*/
|
|
13216
13280
|
|
|
13217
|
-
export { ApiRequest, AppService, AsymmetricalEncryptionService, BatchOptions, BatchResult, CONFIG_SETTINGS_TOKEN, ChannelType, ConfigHTTPOptions, ConfigOptions, DataType, DatabaseDataDemoComponent, DatabaseManagerService, DatabaseStorage, DbService, ErrorDisplaySettings, GlobalStoreOptions, HTTPManagerService, HTTPManagerSignalsService, HTTPManagerStateService, HeadersService, HttpRequestManagerModule, HttpRequestServicesDemoComponent, InvalidFileInfoModel, LocalStorageDemoComponent, LocalStorageManagerService, LocalStorageOptions, LocalStorageSignalsDemoComponent, LocalStorageSignalsManagerService, LoggerService, NormalizedRequestOptionsModel, NotificationMessage, OperationResultModel, PathQueryService, PathTrackerStateModel, PublicMessage, QueryParamsTrackerOptionsModel, QueryTrackerStateModel, Random, RandomHSLColor, RandomHexColor, RandomNumber, RandomNumbers, RandomNumbersUnique, RandomPaletteColor, RandomSignature, RandomStr, RandomVisibleColor, RequestErrorInterceptor, RequestHeadersInterceptor, RequestManagerDemoComponent, RequestManagerStateDemoComponent, RequestOptions, RequestService, RequestSignalsService, RetryOptions, SettingOptions, StateMessage, StateOperationResult, StateStorageOptions, StorageData, StorageOption, StorageType, StoreStateManagerService, StoreStateManagerSignalsService, StoreStateSignalsDemoComponent, StreamType, SymmetricalEncryptionService, TableSchemaDef, UUID, UUID_STR, UploadDemoComponent, UploadValidationErrorModel, UserData, UtilsService, WSOptions, WebSocketMessageService, WithCredentialsInterceptor, calculateBatchProgress, countdown, createChannelName, delayedRetry, isErrorState, isPendingState, isSuccessState, requestPolling, requestStreaming, streamAI, streamAuto, streamEvents, streamJSON, streamNDJSON };
|
|
13281
|
+
export { ApiRequest, AppService, AsymmetricalEncryptionService, BatchOptions, BatchResult, CONFIG_SETTINGS_TOKEN, ChannelType, ConfigHTTPOptions, ConfigOptions, DataType, DatabaseDataDemoComponent, DatabaseManagerService, DatabaseStorage, DbService, ErrorDisplaySettings, GlobalStoreOptions, HTTPManagerService, HTTPManagerSignalsService, HTTPManagerStateService, HeadersService, HttpRequestManagerModule, HttpRequestServicesDemoComponent, InvalidFileInfoModel, LocalStorageDemoComponent, LocalStorageManagerService, LocalStorageOptions, LocalStorageSignalsDemoComponent, LocalStorageSignalsManagerService, LoggerService, NormalizedRequestOptionsModel, NotificationMessage, OperationResultModel, ParsingResultModel, PathQueryService, PathTrackerStateModel, PublicMessage, QueryParamsTrackerOptionsModel, QueryTrackerStateModel, Random, RandomHSLColor, RandomHexColor, RandomNumber, RandomNumbers, RandomNumbersUnique, RandomPaletteColor, RandomSignature, RandomStr, RandomVisibleColor, RequestErrorInterceptor, RequestHeadersInterceptor, RequestManagerDemoComponent, RequestManagerStateDemoComponent, RequestOptions, RequestService, RequestSignalsService, RetryOptions, SettingOptions, StateMessage, StateOperationResult, StateStorageOptions, StorageData, StorageOption, StorageType, StoreStateManagerService, StoreStateManagerSignalsService, StoreStateSignalsDemoComponent, StreamConfigModel, StreamEventMetadataModel, StreamEventModel, StreamOutputModel, StreamProgressModel, StreamType, SymmetricalEncryptionService, TableSchemaDef, UUID, UUID_STR, UploadDemoComponent, UploadValidationErrorModel, UserData, UtilsService, WSOptions, WebSocketMessageService, WithCredentialsInterceptor, calculateBatchProgress, countdown, createChannelName, delayedRetry, isErrorState, isPendingState, isSuccessState, requestPolling, requestStreaming, streamAI, streamAuto, streamEvents, streamJSON, streamNDJSON };
|
|
13218
13282
|
//# sourceMappingURL=http-request-manager.mjs.map
|