http-request-manager 18.12.1 → 18.12.3

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.
@@ -4916,6 +4916,16 @@ class WSOptions {
4916
4916
  }
4917
4917
  }
4918
4918
 
4919
+ class OperationResultModel {
4920
+ constructor(success = false, operation = 'UPDATE') {
4921
+ this.success = success;
4922
+ this.operation = operation;
4923
+ }
4924
+ static adapt(item) {
4925
+ return new OperationResultModel(item?.success ?? false, item?.operation || 'UPDATE');
4926
+ }
4927
+ }
4928
+
4919
4929
  class ObjectMergerService {
4920
4930
  constructor(configOptions) {
4921
4931
  this.configOptions = configOptions;
@@ -6084,6 +6094,8 @@ class HTTPManagerStateService extends ComponentStore {
6084
6094
  this.logger = inject(LoggerService);
6085
6095
  this.error$ = this.httpManagerService.error$;
6086
6096
  this.isPending$ = this.httpManagerService.isPending$.pipe(delay(1));
6097
+ this.operationSuccess = new BehaviorSubject(null);
6098
+ this.operationSuccess$ = this.operationSuccess.asObservable();
6087
6099
  // PAGINATION
6088
6100
  this.page = new BehaviorSubject(0);
6089
6101
  this.page$ = this.page.asObservable();
@@ -6592,6 +6604,7 @@ class HTTPManagerStateService extends ComponentStore {
6592
6604
  .pipe(tap((data) => {
6593
6605
  data = (!data) ? (this.dataType === DataType.ARRAY) ? [] : {} : data;
6594
6606
  this.addData$(data);
6607
+ this.operationSuccess.next(OperationResultModel.adapt({ success: true, operation: 'CREATE' }));
6595
6608
  // Always call wsCommunication - it will queue if not connected
6596
6609
  this.wsCommunication('CREATE', [...options?.path || [], data.id]);
6597
6610
  }), concatMap((data) => {
@@ -6609,6 +6622,7 @@ class HTTPManagerStateService extends ComponentStore {
6609
6622
  .pipe(tap((data) => {
6610
6623
  data = (!data) ? (this.dataType === DataType.ARRAY) ? [] : {} : data;
6611
6624
  this.updateData$(data);
6625
+ this.operationSuccess.next(OperationResultModel.adapt({ success: true, operation: 'UPDATE' }));
6612
6626
  // Always call wsCommunication - it will queue if not connected
6613
6627
  this.wsCommunication('UPDATE', [...options?.path || []]);
6614
6628
  }), concatMap((data) => {
@@ -6626,6 +6640,7 @@ class HTTPManagerStateService extends ComponentStore {
6626
6640
  .pipe(tap((data) => {
6627
6641
  data = (!data) ? (this.dataType === DataType.ARRAY) ? [] : {} : data;
6628
6642
  this.deleteData$(data);
6643
+ this.operationSuccess.next(OperationResultModel.adapt({ success: true, operation: 'DELETE' }));
6629
6644
  // Always call wsCommunication - it will queue if not connected
6630
6645
  this.wsCommunication('DELETE', [...options?.path || []]);
6631
6646
  }), concatMap((data) => {
@@ -7269,6 +7284,20 @@ class StateStorageOptions {
7269
7284
  }
7270
7285
  }
7271
7286
 
7287
+ class StateOperationResult {
7288
+ constructor(success = false, operation = 'UPDATE', key, value, timestamp = Date.now(), error) {
7289
+ this.success = success;
7290
+ this.operation = operation;
7291
+ this.key = key;
7292
+ this.value = value;
7293
+ this.timestamp = timestamp;
7294
+ this.error = error;
7295
+ }
7296
+ static adapt(item) {
7297
+ return new StateOperationResult(item?.success ?? false, item?.operation || 'UPDATE', item?.key, item?.value, item?.timestamp || Date.now(), item?.error);
7298
+ }
7299
+ }
7300
+
7272
7301
  class StoreStateManagerService extends ComponentStore {
7273
7302
  constructor(options = StateStorageOptions.adapt()) {
7274
7303
  super(StoreStateManagerService.init(options));
@@ -7277,6 +7306,8 @@ class StoreStateManagerService extends ComponentStore {
7277
7306
  this.subscriptions = new Subscription;
7278
7307
  this.settings = null;
7279
7308
  this.isRestoring = false;
7309
+ this.operationResult = new BehaviorSubject(null);
7310
+ this.operationResult$ = this.operationResult.asObservable();
7280
7311
  // Selectors
7281
7312
  this.data$ = this.select((state) => {
7282
7313
  const model = this.options.model;
@@ -7323,6 +7354,67 @@ class StoreStateManagerService extends ComponentStore {
7323
7354
  data: state
7324
7355
  });
7325
7356
  }
7357
+ createRecord(key, value) {
7358
+ try {
7359
+ this.updateData({ [key]: value });
7360
+ this.operationResult.next(StateOperationResult.adapt({
7361
+ success: true,
7362
+ operation: 'CREATE',
7363
+ key,
7364
+ value,
7365
+ }));
7366
+ }
7367
+ catch (error) {
7368
+ this.operationResult.next(StateOperationResult.adapt({
7369
+ success: false,
7370
+ operation: 'CREATE',
7371
+ key,
7372
+ error: error?.message || 'Create failed',
7373
+ }));
7374
+ }
7375
+ }
7376
+ updateRecord(key, value) {
7377
+ try {
7378
+ this.updateData({ [key]: value });
7379
+ this.operationResult.next(StateOperationResult.adapt({
7380
+ success: true,
7381
+ operation: 'UPDATE',
7382
+ key,
7383
+ value,
7384
+ }));
7385
+ }
7386
+ catch (error) {
7387
+ this.operationResult.next(StateOperationResult.adapt({
7388
+ success: false,
7389
+ operation: 'UPDATE',
7390
+ key,
7391
+ error: error?.message || 'Update failed',
7392
+ }));
7393
+ }
7394
+ }
7395
+ deleteRecord(key) {
7396
+ try {
7397
+ const currentState = this.get();
7398
+ if (currentState && key in currentState) {
7399
+ const { [key]: removed, ...rest } = currentState;
7400
+ this.setState(rest);
7401
+ this.updateState(rest);
7402
+ }
7403
+ this.operationResult.next(StateOperationResult.adapt({
7404
+ success: true,
7405
+ operation: 'DELETE',
7406
+ key,
7407
+ }));
7408
+ }
7409
+ catch (error) {
7410
+ this.operationResult.next(StateOperationResult.adapt({
7411
+ success: false,
7412
+ operation: 'DELETE',
7413
+ key,
7414
+ error: error?.message || 'Delete failed',
7415
+ }));
7416
+ }
7417
+ }
7326
7418
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StoreStateManagerService, deps: [{ token: StateStorageOptions }], target: i0.ɵɵFactoryTarget.Injectable }); }
7327
7419
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StoreStateManagerService, providedIn: 'root' }); }
7328
7420
  }
@@ -7339,6 +7431,8 @@ class StoreStateManagerSignalsService {
7339
7431
  this.state = signal(null);
7340
7432
  this.isRestoring = false;
7341
7433
  this.settings = null;
7434
+ this.operationResultSignal = signal(null);
7435
+ this.operationResult = this.operationResultSignal.asReadonly();
7342
7436
  // Public readonly signals for consumers
7343
7437
  this.data = this.state.asReadonly();
7344
7438
  // Computed signal for transformed data
@@ -7402,6 +7496,67 @@ class StoreStateManagerSignalsService {
7402
7496
  this.state.set(newState);
7403
7497
  this.updateState(newState);
7404
7498
  }
7499
+ createRecord(key, value) {
7500
+ try {
7501
+ this.updateData({ [key]: value });
7502
+ this.operationResultSignal.set(StateOperationResult.adapt({
7503
+ success: true,
7504
+ operation: 'CREATE',
7505
+ key,
7506
+ value,
7507
+ }));
7508
+ }
7509
+ catch (error) {
7510
+ this.operationResultSignal.set(StateOperationResult.adapt({
7511
+ success: false,
7512
+ operation: 'CREATE',
7513
+ key,
7514
+ error: error?.message || 'Create failed',
7515
+ }));
7516
+ }
7517
+ }
7518
+ updateRecord(key, value) {
7519
+ try {
7520
+ this.updateData({ [key]: value });
7521
+ this.operationResultSignal.set(StateOperationResult.adapt({
7522
+ success: true,
7523
+ operation: 'UPDATE',
7524
+ key,
7525
+ value,
7526
+ }));
7527
+ }
7528
+ catch (error) {
7529
+ this.operationResultSignal.set(StateOperationResult.adapt({
7530
+ success: false,
7531
+ operation: 'UPDATE',
7532
+ key,
7533
+ error: error?.message || 'Update failed',
7534
+ }));
7535
+ }
7536
+ }
7537
+ deleteRecord(key) {
7538
+ try {
7539
+ const currentState = this.state();
7540
+ if (currentState && key in currentState) {
7541
+ const { [key]: removed, ...rest } = currentState;
7542
+ this.state.set(rest);
7543
+ this.updateState(rest);
7544
+ }
7545
+ this.operationResultSignal.set(StateOperationResult.adapt({
7546
+ success: true,
7547
+ operation: 'DELETE',
7548
+ key,
7549
+ }));
7550
+ }
7551
+ catch (error) {
7552
+ this.operationResultSignal.set(StateOperationResult.adapt({
7553
+ success: false,
7554
+ operation: 'DELETE',
7555
+ key,
7556
+ error: error?.message || 'Delete failed',
7557
+ }));
7558
+ }
7559
+ }
7405
7560
  resetState() {
7406
7561
  if (!this.settings)
7407
7562
  return;
@@ -11608,5 +11763,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
11608
11763
  * Generated bundle index. Do not edit.
11609
11764
  */
11610
11765
 
11611
- 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, NotificationMessage, PathQueryService, PublicMessage, Random, RandomHSLColor, RandomHexColor, RandomNumber, RandomNumbers, RandomNumbersUnique, RandomPaletteColor, RandomSignature, RandomStr, RandomVisibleColor, RequestErrorInterceptor, RequestHeadersInterceptor, RequestManagerDemoComponent, RequestManagerStateDemoComponent, RequestOptions, RequestService, RequestSignalsService, RetryOptions, SettingOptions, StateMessage, 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 };
11766
+ 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, NotificationMessage, OperationResultModel, PathQueryService, PublicMessage, 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 };
11612
11767
  //# sourceMappingURL=http-request-manager.mjs.map