http-request-manager 18.11.21 → 18.11.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.
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ export class UsersComponent {
|
|
|
128
128
|
|
|
129
129
|
ngOnInit() {
|
|
130
130
|
this.httpManager.getRequest(
|
|
131
|
-
ApiRequest.adapt({ path: ['users'] })
|
|
131
|
+
ApiRequest.adapt({ path: ['users'], displaySuccess: true, successMessage: 'Loaded users!' })
|
|
132
132
|
).subscribe();
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -218,6 +218,9 @@ export class AppModule { }
|
|
|
218
218
|
| `retry` | `RetryOptions` | Default retry configuration | `{ times: 0, delay: 3 }` |
|
|
219
219
|
| `stream` | `boolean` | Enable streaming by default | `false` |
|
|
220
220
|
| `displayError` | `boolean` | Show toast errors by default | `false` |
|
|
221
|
+
| `displaySuccess` | `boolean` | Show toast on success by default | `false` |
|
|
222
|
+
| `successMessage` | `string` | Custom success toast message (optional) | `undefined` |
|
|
223
|
+
| `errorMessage` | `string` | Custom error toast message (optional, overrides default) | `undefined` |
|
|
221
224
|
|
|
222
225
|
#### Local Storage Options (`LocalStorageOptions`)
|
|
223
226
|
|
|
@@ -2935,15 +2935,17 @@ class RetryOptions {
|
|
|
2935
2935
|
}
|
|
2936
2936
|
|
|
2937
2937
|
class BatchOptions {
|
|
2938
|
-
constructor(mode = 'sequential', stopOnError = false, concurrency = 3, ignoreErrors = false, logErrors = true) {
|
|
2938
|
+
constructor(mode = 'sequential', stopOnError = false, concurrency = 3, ignoreErrors = false, logErrors = true, displaySuccess, displayError) {
|
|
2939
2939
|
this.mode = mode;
|
|
2940
2940
|
this.stopOnError = stopOnError;
|
|
2941
2941
|
this.concurrency = concurrency;
|
|
2942
2942
|
this.ignoreErrors = ignoreErrors;
|
|
2943
2943
|
this.logErrors = logErrors;
|
|
2944
|
+
this.displaySuccess = displaySuccess;
|
|
2945
|
+
this.displayError = displayError;
|
|
2944
2946
|
}
|
|
2945
2947
|
static adapt(item) {
|
|
2946
|
-
return new BatchOptions(item?.mode ?? 'sequential', item?.stopOnError ?? false, item?.concurrency ?? 3, item?.ignoreErrors ?? false, item?.logErrors !== false);
|
|
2948
|
+
return new BatchOptions(item?.mode ?? 'sequential', item?.stopOnError ?? false, item?.concurrency ?? 3, item?.ignoreErrors ?? false, item?.logErrors !== false, item?.displaySuccess ?? false, item?.displayError ?? false);
|
|
2947
2949
|
}
|
|
2948
2950
|
}
|
|
2949
2951
|
|
|
@@ -2988,7 +2990,7 @@ var DataType;
|
|
|
2988
2990
|
})(DataType || (DataType = {}));
|
|
2989
2991
|
|
|
2990
2992
|
class ConfigHTTPOptions {
|
|
2991
|
-
constructor(server = '', path, headers, polling, retry, stream, displayError) {
|
|
2993
|
+
constructor(server = '', path, headers, polling, retry, stream, displayError, displaySuccess) {
|
|
2992
2994
|
this.server = server;
|
|
2993
2995
|
this.path = path;
|
|
2994
2996
|
this.headers = headers;
|
|
@@ -2996,11 +2998,12 @@ class ConfigHTTPOptions {
|
|
|
2996
2998
|
this.retry = retry;
|
|
2997
2999
|
this.stream = stream;
|
|
2998
3000
|
this.displayError = displayError;
|
|
3001
|
+
this.displaySuccess = displaySuccess;
|
|
2999
3002
|
}
|
|
3000
3003
|
static adapt(item) {
|
|
3001
3004
|
const server = Array.isArray(item?.server) ? item.server.join('/') : item?.server || '';
|
|
3002
3005
|
const retryOptions = item?.retry ? RetryOptions.adapt(item.retry) : RetryOptions.adapt();
|
|
3003
|
-
return new ConfigHTTPOptions(server, (item?.path) ? item.path : [], (item?.headers) ? item.headers : {}, item?.polling ? Math.floor(item.polling) : 0, retryOptions, (item?.stream) ? item.stream : false, (item?.displayError) ? item.displayError : false);
|
|
3006
|
+
return new ConfigHTTPOptions(server, (item?.path) ? item.path : [], (item?.headers) ? item.headers : {}, item?.polling ? Math.floor(item.polling) : 0, retryOptions, (item?.stream) ? item.stream : false, (item?.displayError) ? item.displayError : false, (item?.displaySuccess) ? item.displaySuccess : false);
|
|
3004
3007
|
}
|
|
3005
3008
|
}
|
|
3006
3009
|
|
|
@@ -3618,9 +3621,13 @@ class HTTPManagerService extends RequestService {
|
|
|
3618
3621
|
const func = this.getRecordRequest;
|
|
3619
3622
|
const requests = this.createRequest(func, updatedOptions);
|
|
3620
3623
|
return this.createObservable(updatedOptions, requests, func.name)
|
|
3621
|
-
.pipe(tap(data =>
|
|
3624
|
+
.pipe(tap(data => {
|
|
3625
|
+
this.data.next(data);
|
|
3626
|
+
if (updatedOptions.displaySuccess)
|
|
3627
|
+
this.handleSuccessWithSnackBar(updatedOptions.successMessage);
|
|
3628
|
+
})).pipe(finalize(() => this.isPending.next(false)), catchError((err) => {
|
|
3622
3629
|
if (updatedOptions.displayError)
|
|
3623
|
-
this.handleErrorWithSnackBar(err);
|
|
3630
|
+
this.handleErrorWithSnackBar(err, updatedOptions.errorMessage || err?.message);
|
|
3624
3631
|
this.isPending.next(false);
|
|
3625
3632
|
return this.handleError(err);
|
|
3626
3633
|
}));
|
|
@@ -3631,10 +3638,13 @@ class HTTPManagerService extends RequestService {
|
|
|
3631
3638
|
const updatedOptions = this.defineReqOptions(options, params);
|
|
3632
3639
|
const func = this.createRecordRequest;
|
|
3633
3640
|
const requests = this.createRequest(func, updatedOptions, data);
|
|
3634
|
-
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data =>
|
|
3635
|
-
|
|
3641
|
+
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data => {
|
|
3642
|
+
this.data.next(data);
|
|
3643
|
+
if (updatedOptions.displaySuccess)
|
|
3644
|
+
this.handleSuccessWithSnackBar(updatedOptions.successMessage);
|
|
3645
|
+
}), finalize(() => this.isPending.next(false)), catchError((err) => {
|
|
3636
3646
|
if (updatedOptions.displayError)
|
|
3637
|
-
this.handleErrorWithSnackBar(err);
|
|
3647
|
+
this.handleErrorWithSnackBar(err, updatedOptions.errorMessage || err?.message);
|
|
3638
3648
|
this.isPending.next(false);
|
|
3639
3649
|
return this.handleError(err);
|
|
3640
3650
|
}));
|
|
@@ -3645,10 +3655,13 @@ class HTTPManagerService extends RequestService {
|
|
|
3645
3655
|
const updatedOptions = this.defineReqOptions(options, params);
|
|
3646
3656
|
const func = this.updateRecordRequest;
|
|
3647
3657
|
const requests = this.createRequest(func, updatedOptions, data);
|
|
3648
|
-
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data =>
|
|
3649
|
-
|
|
3658
|
+
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data => {
|
|
3659
|
+
this.data.next(data);
|
|
3660
|
+
if (updatedOptions.displaySuccess)
|
|
3661
|
+
this.handleSuccessWithSnackBar(updatedOptions.successMessage);
|
|
3662
|
+
}), finalize(() => this.isPending.next(false)), catchError((err) => {
|
|
3650
3663
|
if (updatedOptions.displayError)
|
|
3651
|
-
this.handleErrorWithSnackBar(err);
|
|
3664
|
+
this.handleErrorWithSnackBar(err, updatedOptions.errorMessage || err?.message);
|
|
3652
3665
|
this.isPending.next(false);
|
|
3653
3666
|
return this.handleError(err);
|
|
3654
3667
|
}));
|
|
@@ -3659,10 +3672,13 @@ class HTTPManagerService extends RequestService {
|
|
|
3659
3672
|
const updatedOptions = this.defineReqOptions(options, params);
|
|
3660
3673
|
const func = this.deleteRecordRequest;
|
|
3661
3674
|
const requests = this.createRequest(func, updatedOptions);
|
|
3662
|
-
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data =>
|
|
3663
|
-
|
|
3675
|
+
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data => {
|
|
3676
|
+
this.data.next(data);
|
|
3677
|
+
if (updatedOptions.displaySuccess)
|
|
3678
|
+
this.handleSuccessWithSnackBar(updatedOptions.successMessage);
|
|
3679
|
+
}), finalize(() => this.isPending.next(false)), catchError((err) => {
|
|
3664
3680
|
if (updatedOptions.displayError)
|
|
3665
|
-
this.handleErrorWithSnackBar(err);
|
|
3681
|
+
this.handleErrorWithSnackBar(err, updatedOptions.errorMessage || err?.message);
|
|
3666
3682
|
this.isPending.next(false);
|
|
3667
3683
|
return this.handleError(err);
|
|
3668
3684
|
}));
|
|
@@ -3751,9 +3767,9 @@ class HTTPManagerService extends RequestService {
|
|
|
3751
3767
|
this.error.next(error.message || `${error.status} - ${error.statusText}`);
|
|
3752
3768
|
return throwError(() => error);
|
|
3753
3769
|
}
|
|
3754
|
-
handleErrorWithSnackBar(error) {
|
|
3770
|
+
handleErrorWithSnackBar(error, message) {
|
|
3755
3771
|
const displayError = ToastDisplay.adapt({
|
|
3756
|
-
message: error.message || `${error.status} - ${error.statusText}`,
|
|
3772
|
+
message: message || error.message || `${error.status} - ${error.statusText}`,
|
|
3757
3773
|
action: 'OK',
|
|
3758
3774
|
color: ToastColors.ERROR,
|
|
3759
3775
|
icon: 'error',
|
|
@@ -3761,6 +3777,16 @@ class HTTPManagerService extends RequestService {
|
|
|
3761
3777
|
});
|
|
3762
3778
|
this.toastMessage.toastMessage(displayError);
|
|
3763
3779
|
}
|
|
3780
|
+
handleSuccessWithSnackBar(message) {
|
|
3781
|
+
const displaySuccess = ToastDisplay.adapt({
|
|
3782
|
+
message: message || 'Success',
|
|
3783
|
+
action: 'OK',
|
|
3784
|
+
color: ToastColors.SUCCESS,
|
|
3785
|
+
icon: 'check_circle',
|
|
3786
|
+
duration: 3 * 1000, //3 seconds
|
|
3787
|
+
});
|
|
3788
|
+
this.toastMessage.toastMessage(displaySuccess);
|
|
3789
|
+
}
|
|
3764
3790
|
stopPolling() {
|
|
3765
3791
|
this.isPending.next(false);
|
|
3766
3792
|
this.polling$.next();
|
|
@@ -3796,14 +3822,17 @@ class HTTPManagerService extends RequestService {
|
|
|
3796
3822
|
* @param options Optional batch configuration
|
|
3797
3823
|
* @returns Observable emitting array of data when all requests complete
|
|
3798
3824
|
*/
|
|
3799
|
-
getSequentialRequest(requests, options) {
|
|
3825
|
+
getSequentialRequest(requests, options, successMessage, errorMessage) {
|
|
3800
3826
|
const batchOptions = BatchOptions.adapt(options);
|
|
3801
3827
|
const results = new Array(requests.length);
|
|
3802
3828
|
return from(requests).pipe(concatMap((req, index) => {
|
|
3803
|
-
return this.getRequest(req).pipe(tap(data => {
|
|
3829
|
+
return this.getRequest(req, undefined).pipe(tap(data => {
|
|
3804
3830
|
results[index] = data;
|
|
3805
3831
|
}), catchError(error => this.handleSequentialError(req, error, index, batchOptions)));
|
|
3806
|
-
}), toArray(),
|
|
3832
|
+
}), toArray(), tap(() => {
|
|
3833
|
+
if (batchOptions.displaySuccess)
|
|
3834
|
+
this.handleSuccessWithSnackBar(successMessage);
|
|
3835
|
+
}), map(() => results));
|
|
3807
3836
|
}
|
|
3808
3837
|
/**
|
|
3809
3838
|
* Execute requests in parallel with concurrency control
|
|
@@ -3811,15 +3840,18 @@ class HTTPManagerService extends RequestService {
|
|
|
3811
3840
|
* @param options Optional batch configuration with concurrency limit
|
|
3812
3841
|
* @returns Observable emitting array of data when all requests complete
|
|
3813
3842
|
*/
|
|
3814
|
-
getParallelRequest(requests, options) {
|
|
3843
|
+
getParallelRequest(requests, options, successMessage, errorMessage) {
|
|
3815
3844
|
const batchOptions = BatchOptions.adapt(options);
|
|
3816
3845
|
const concurrency = batchOptions.concurrency || 3;
|
|
3817
3846
|
const results = new Array(requests.length);
|
|
3818
3847
|
return from(requests).pipe(mergeMap((req, index) => {
|
|
3819
|
-
return this.getRequest(req).pipe(tap(data => {
|
|
3848
|
+
return this.getRequest(req, undefined).pipe(tap(data => {
|
|
3820
3849
|
results[index] = data;
|
|
3821
3850
|
}), catchError(error => this.handleParallelError(req, error, index, batchOptions)));
|
|
3822
|
-
}, concurrency), toArray(),
|
|
3851
|
+
}, concurrency), toArray(), tap(() => {
|
|
3852
|
+
if (batchOptions.displaySuccess)
|
|
3853
|
+
this.handleSuccessWithSnackBar(successMessage);
|
|
3854
|
+
}), map(() => results));
|
|
3823
3855
|
}
|
|
3824
3856
|
/**
|
|
3825
3857
|
* Execute multiple HTTP requests and emit individual state changes in real-time
|
|
@@ -4273,9 +4305,13 @@ class HTTPManagerSignalsService extends RequestSignalsService {
|
|
|
4273
4305
|
const updatedOptions = this.defineReqOptions(options, params);
|
|
4274
4306
|
const func = this.getRecordRequest;
|
|
4275
4307
|
const requests = this.createRequest(func, updatedOptions);
|
|
4276
|
-
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data =>
|
|
4308
|
+
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data => {
|
|
4309
|
+
this.data.set(data);
|
|
4310
|
+
if (updatedOptions.displaySuccess)
|
|
4311
|
+
this.handleSuccessWithSnackBar(updatedOptions.successMessage);
|
|
4312
|
+
}), finalize(() => this.isPending.set(false)), catchError((err) => {
|
|
4277
4313
|
if (updatedOptions.displayError)
|
|
4278
|
-
this.handleErrorWithSnackBar(err);
|
|
4314
|
+
this.handleErrorWithSnackBar(err, updatedOptions.errorMessage || err?.message);
|
|
4279
4315
|
this.isPending.set(false);
|
|
4280
4316
|
return this.handleError(err);
|
|
4281
4317
|
}));
|
|
@@ -4286,9 +4322,13 @@ class HTTPManagerSignalsService extends RequestSignalsService {
|
|
|
4286
4322
|
const updatedOptions = this.defineReqOptions(options, params);
|
|
4287
4323
|
const func = this.createRecordRequest;
|
|
4288
4324
|
const requests = this.createRequest(func, updatedOptions, data);
|
|
4289
|
-
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data =>
|
|
4325
|
+
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data => {
|
|
4326
|
+
this.data.set(data);
|
|
4327
|
+
if (updatedOptions.displaySuccess)
|
|
4328
|
+
this.handleSuccessWithSnackBar(updatedOptions.successMessage);
|
|
4329
|
+
}), finalize(() => this.isPending.set(false)), catchError((err) => {
|
|
4290
4330
|
if (updatedOptions.displayError)
|
|
4291
|
-
this.handleErrorWithSnackBar(err);
|
|
4331
|
+
this.handleErrorWithSnackBar(err, updatedOptions.errorMessage);
|
|
4292
4332
|
this.isPending.set(false);
|
|
4293
4333
|
return this.handleError(err);
|
|
4294
4334
|
}));
|
|
@@ -4299,9 +4339,13 @@ class HTTPManagerSignalsService extends RequestSignalsService {
|
|
|
4299
4339
|
const updatedOptions = this.defineReqOptions(options, params);
|
|
4300
4340
|
const func = this.updateRecordRequest;
|
|
4301
4341
|
const requests = this.createRequest(func, updatedOptions, data);
|
|
4302
|
-
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data =>
|
|
4342
|
+
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data => {
|
|
4343
|
+
this.data.set(data);
|
|
4344
|
+
if (updatedOptions.displaySuccess)
|
|
4345
|
+
this.handleSuccessWithSnackBar(updatedOptions.successMessage);
|
|
4346
|
+
}), finalize(() => this.isPending.set(false)), catchError((err) => {
|
|
4303
4347
|
if (updatedOptions.displayError)
|
|
4304
|
-
this.handleErrorWithSnackBar(err);
|
|
4348
|
+
this.handleErrorWithSnackBar(err, updatedOptions.errorMessage);
|
|
4305
4349
|
this.isPending.set(false);
|
|
4306
4350
|
return this.handleError(err);
|
|
4307
4351
|
}));
|
|
@@ -4312,9 +4356,13 @@ class HTTPManagerSignalsService extends RequestSignalsService {
|
|
|
4312
4356
|
const updatedOptions = this.defineReqOptions(options, params);
|
|
4313
4357
|
const func = this.deleteRecordRequest;
|
|
4314
4358
|
const requests = this.createRequest(func, updatedOptions);
|
|
4315
|
-
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data =>
|
|
4359
|
+
return this.createObservable(updatedOptions, requests, func.name).pipe(tap(data => {
|
|
4360
|
+
this.data.set(data);
|
|
4361
|
+
if (updatedOptions.displaySuccess)
|
|
4362
|
+
this.handleSuccessWithSnackBar(updatedOptions.successMessage);
|
|
4363
|
+
}), finalize(() => this.isPending.set(false)), catchError((err) => {
|
|
4316
4364
|
if (updatedOptions.displayError)
|
|
4317
|
-
this.handleErrorWithSnackBar(err);
|
|
4365
|
+
this.handleErrorWithSnackBar(err, updatedOptions.errorMessage);
|
|
4318
4366
|
this.isPending.set(false);
|
|
4319
4367
|
return this.handleError(err);
|
|
4320
4368
|
}));
|
|
@@ -4399,9 +4447,9 @@ class HTTPManagerSignalsService extends RequestSignalsService {
|
|
|
4399
4447
|
this.error.set(error.message || `${error.status} - ${error.statusText}`);
|
|
4400
4448
|
return throwError(() => error);
|
|
4401
4449
|
}
|
|
4402
|
-
handleErrorWithSnackBar(error) {
|
|
4450
|
+
handleErrorWithSnackBar(error, message) {
|
|
4403
4451
|
const displayError = ToastDisplay.adapt({
|
|
4404
|
-
message: error.message || `${error.status} - ${error.statusText}`,
|
|
4452
|
+
message: message || error.message || `${error.status} - ${error.statusText}`,
|
|
4405
4453
|
action: 'OK',
|
|
4406
4454
|
color: ToastColors.ERROR,
|
|
4407
4455
|
icon: 'error',
|
|
@@ -4409,6 +4457,16 @@ class HTTPManagerSignalsService extends RequestSignalsService {
|
|
|
4409
4457
|
});
|
|
4410
4458
|
this.toastMessage.toastMessage(displayError);
|
|
4411
4459
|
}
|
|
4460
|
+
handleSuccessWithSnackBar(message) {
|
|
4461
|
+
const displaySuccess = ToastDisplay.adapt({
|
|
4462
|
+
message: message || 'Success',
|
|
4463
|
+
action: 'OK',
|
|
4464
|
+
color: ToastColors.SUCCESS,
|
|
4465
|
+
icon: 'check_circle',
|
|
4466
|
+
duration: 3 * 1000,
|
|
4467
|
+
});
|
|
4468
|
+
this.toastMessage.toastMessage(displaySuccess);
|
|
4469
|
+
}
|
|
4412
4470
|
stopPolling() {
|
|
4413
4471
|
this.isPending.set(false);
|
|
4414
4472
|
this.polling$.next();
|
|
@@ -4444,14 +4502,17 @@ class HTTPManagerSignalsService extends RequestSignalsService {
|
|
|
4444
4502
|
* @param options Optional batch configuration
|
|
4445
4503
|
* @returns Observable emitting array of data when all requests complete
|
|
4446
4504
|
*/
|
|
4447
|
-
getSequentialRequest(requests, options) {
|
|
4505
|
+
getSequentialRequest(requests, options, successMessage, errorMessage) {
|
|
4448
4506
|
const batchOptions = BatchOptions.adapt(options);
|
|
4449
4507
|
const results = new Array(requests.length);
|
|
4450
4508
|
return from(requests).pipe(concatMap((req, index) => {
|
|
4451
|
-
return this.getRequest(req).pipe(tap(data => {
|
|
4509
|
+
return this.getRequest(req, undefined).pipe(tap(data => {
|
|
4452
4510
|
results[index] = data;
|
|
4453
4511
|
}), catchError(error => this.handleSequentialError(req, error, index, batchOptions)));
|
|
4454
|
-
}), toArray(),
|
|
4512
|
+
}), toArray(), tap(() => {
|
|
4513
|
+
if (batchOptions.displaySuccess)
|
|
4514
|
+
this.handleSuccessWithSnackBar(successMessage);
|
|
4515
|
+
}), map(() => results));
|
|
4455
4516
|
}
|
|
4456
4517
|
/**
|
|
4457
4518
|
* Execute requests in parallel with concurrency control
|
|
@@ -4459,15 +4520,18 @@ class HTTPManagerSignalsService extends RequestSignalsService {
|
|
|
4459
4520
|
* @param options Optional batch configuration with concurrency limit
|
|
4460
4521
|
* @returns Observable emitting array of data when all requests complete
|
|
4461
4522
|
*/
|
|
4462
|
-
getParallelRequest(requests, options) {
|
|
4523
|
+
getParallelRequest(requests, options, successMessage, errorMessage) {
|
|
4463
4524
|
const batchOptions = BatchOptions.adapt(options);
|
|
4464
4525
|
const concurrency = batchOptions.concurrency || 3;
|
|
4465
4526
|
const results = new Array(requests.length);
|
|
4466
4527
|
return from(requests).pipe(mergeMap((req, index) => {
|
|
4467
|
-
return this.getRequest(req).pipe(tap(data => {
|
|
4528
|
+
return this.getRequest(req, undefined).pipe(tap(data => {
|
|
4468
4529
|
results[index] = data;
|
|
4469
4530
|
}), catchError(error => this.handleParallelError(req, error, index, batchOptions)));
|
|
4470
|
-
}, concurrency), toArray(),
|
|
4531
|
+
}, concurrency), toArray(), tap(() => {
|
|
4532
|
+
if (batchOptions.displaySuccess)
|
|
4533
|
+
this.handleSuccessWithSnackBar(successMessage);
|
|
4534
|
+
}), map(() => results));
|
|
4471
4535
|
}
|
|
4472
4536
|
/**
|
|
4473
4537
|
* Execute multiple HTTP requests and emit individual state changes in real-time
|
|
@@ -4571,7 +4635,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
4571
4635
|
}] }] });
|
|
4572
4636
|
|
|
4573
4637
|
class ApiRequest {
|
|
4574
|
-
constructor(server = '', path, headers, adapter, mapper, polling, retry, stream, streamType, displayError, saveAs, fileContentHeader, ws, env) {
|
|
4638
|
+
constructor(server = '', path, headers, adapter, mapper, polling, retry, stream, streamType, displayError, displaySuccess, successMessage, errorMessage, saveAs, fileContentHeader, ws, env) {
|
|
4575
4639
|
this.server = server;
|
|
4576
4640
|
this.path = path;
|
|
4577
4641
|
this.headers = headers;
|
|
@@ -4582,6 +4646,9 @@ class ApiRequest {
|
|
|
4582
4646
|
this.stream = stream;
|
|
4583
4647
|
this.streamType = streamType;
|
|
4584
4648
|
this.displayError = displayError;
|
|
4649
|
+
this.displaySuccess = displaySuccess;
|
|
4650
|
+
this.successMessage = successMessage;
|
|
4651
|
+
this.errorMessage = errorMessage;
|
|
4585
4652
|
this.saveAs = saveAs;
|
|
4586
4653
|
this.fileContentHeader = fileContentHeader;
|
|
4587
4654
|
this.ws = ws;
|
|
@@ -4589,7 +4656,7 @@ class ApiRequest {
|
|
|
4589
4656
|
}
|
|
4590
4657
|
static adapt(item) {
|
|
4591
4658
|
const server = Array.isArray(item?.server) ? item.server.join('/') : item?.server || '';
|
|
4592
|
-
return new ApiRequest(server,
|
|
4659
|
+
return new ApiRequest(server, item?.path ? item.path : [], item?.headers ? item.headers : {}, item?.adapter, item?.mapper, item?.polling ? Math.floor(item.polling) : 0, item?.retry ? RetryOptions.adapt(item.retry) : RetryOptions.adapt(), item?.stream ? item.stream : false, item?.streamType || StreamType.AI_STREAMING, item?.displayError ? item.displayError : false, item?.displaySuccess ? item.displaySuccess : false, item?.successMessage, item?.errorMessage, item?.saveAs, item?.fileContentHeader, item?.ws, item?.env || 'dev');
|
|
4593
4660
|
}
|
|
4594
4661
|
}
|
|
4595
4662
|
|