@plyaz/types 1.7.17 → 1.7.18
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.
|
@@ -54,7 +54,7 @@ export type RetryInterceptor = NonNullable<FetchffRequestConfig['onRetry']>;
|
|
|
54
54
|
* Extends fetchff's RequestConfig with our abstraction layer
|
|
55
55
|
* Supports ALL fetchff configuration options
|
|
56
56
|
*/
|
|
57
|
-
export interface ApiConfig extends Partial<Omit<FetchffRequestConfig, 'retry' | 'cache' | 'cacheTime' | 'staleTime' | 'skipCache' | 'cacheErrors' | 'cacheKey' | 'cacheBuster' | 'pollingInterval' | 'pollingDelay' | 'maxPollingAttempts' | 'shouldStopPolling' | 'data' | 'headers' | 'onRequest' | 'onResponse' | 'onError' | 'onRetry'>> {
|
|
57
|
+
export interface ApiConfig<TApiPackageError = unknown> extends Partial<Omit<FetchffRequestConfig, 'retry' | 'cache' | 'cacheTime' | 'staleTime' | 'skipCache' | 'cacheErrors' | 'cacheKey' | 'cacheBuster' | 'pollingInterval' | 'pollingDelay' | 'maxPollingAttempts' | 'shouldStopPolling' | 'data' | 'headers' | 'onRequest' | 'onResponse' | 'onError' | 'onRetry'>> {
|
|
58
58
|
/** Base URL for all requests */
|
|
59
59
|
baseURL?: string;
|
|
60
60
|
/** Default HTTP method */
|
|
@@ -325,7 +325,7 @@ export interface ApiConfig extends Partial<Omit<FetchffRequestConfig, 'retry' |
|
|
|
325
325
|
* });
|
|
326
326
|
* ```
|
|
327
327
|
*/
|
|
328
|
-
errorHandlers?: ErrorEventHandlers
|
|
328
|
+
errorHandlers?: ErrorEventHandlers<TApiPackageError>;
|
|
329
329
|
/**
|
|
330
330
|
* Configuration event handlers for monitoring config changes and updates
|
|
331
331
|
* Track when global config is updated, reset, or when presets are applied
|
|
@@ -88,25 +88,25 @@ export interface ApiPackageErrorOptionsErrorDetail<ValueGiven, AllowedValues, Co
|
|
|
88
88
|
* Event handler types for API package errors
|
|
89
89
|
* Note: ApiPackageError is not imported here to avoid implementation dependencies
|
|
90
90
|
*/
|
|
91
|
-
export interface ErrorEventHandlers {
|
|
92
|
-
onValidationError?: ((error:
|
|
93
|
-
onNetworkError?: ((error:
|
|
94
|
-
onAuthenticationError?: ((error:
|
|
95
|
-
onAuthorizationError?: ((error:
|
|
96
|
-
onRateLimitError?: ((error:
|
|
97
|
-
onTimeoutError?: ((error:
|
|
98
|
-
onConflictError?: ((error:
|
|
99
|
-
onNotFoundError?: ((error:
|
|
100
|
-
onServerError?: ((error:
|
|
101
|
-
onClientError?: ((error:
|
|
102
|
-
onExternalServiceError?: ((error:
|
|
103
|
-
onCacheError?: ((error:
|
|
104
|
-
onHeadersError?: ((error:
|
|
105
|
-
onRetryError?: ((error:
|
|
106
|
-
onStrategyError?: ((error:
|
|
107
|
-
onRegionalError?: ((error:
|
|
108
|
-
onUnknownError?: ((error:
|
|
109
|
-
onAnyError?: ((error:
|
|
91
|
+
export interface ErrorEventHandlers<ApiPackageError> {
|
|
92
|
+
onValidationError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
93
|
+
onNetworkError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
94
|
+
onAuthenticationError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
95
|
+
onAuthorizationError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
96
|
+
onRateLimitError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
97
|
+
onTimeoutError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
98
|
+
onConflictError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
99
|
+
onNotFoundError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
100
|
+
onServerError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
101
|
+
onClientError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
102
|
+
onExternalServiceError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
103
|
+
onCacheError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
104
|
+
onHeadersError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
105
|
+
onRetryError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
106
|
+
onStrategyError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
107
|
+
onRegionalError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
108
|
+
onUnknownError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
109
|
+
onAnyError?: ((error: ApiPackageError) => void) | Array<(error: ApiPackageError) => void>;
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* Options for error handler registration
|
|
@@ -625,6 +625,76 @@ export interface CacheInvalidateEvent extends BaseEvent {
|
|
|
625
625
|
* Union type for all cache event types
|
|
626
626
|
*/
|
|
627
627
|
export type CacheEventData = CacheHitEvent | CacheMissEvent | CacheInvalidateEvent;
|
|
628
|
+
/**
|
|
629
|
+
* Client conflict event
|
|
630
|
+
*/
|
|
631
|
+
export interface ClientConflictEvent extends BaseEvent {
|
|
632
|
+
type: string;
|
|
633
|
+
data: Record<string, unknown>;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Client debug event
|
|
637
|
+
*/
|
|
638
|
+
export interface ClientDebugEvent extends BaseEvent {
|
|
639
|
+
type: string;
|
|
640
|
+
data: Record<string, unknown>;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Client created event
|
|
644
|
+
*/
|
|
645
|
+
export interface ClientCreatedEvent extends BaseEvent {
|
|
646
|
+
type: string;
|
|
647
|
+
data: {
|
|
648
|
+
clientId: string;
|
|
649
|
+
config: Record<string, unknown>;
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Request start event (client-level)
|
|
654
|
+
*/
|
|
655
|
+
export interface RequestStartEvent extends BaseEvent {
|
|
656
|
+
type: 'request:start';
|
|
657
|
+
data: {
|
|
658
|
+
url?: string;
|
|
659
|
+
method?: string;
|
|
660
|
+
timestamp: number;
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Response received event
|
|
665
|
+
*/
|
|
666
|
+
export interface ResponseReceivedEvent extends BaseEvent {
|
|
667
|
+
type: 'response:received';
|
|
668
|
+
data: {
|
|
669
|
+
url?: string;
|
|
670
|
+
status?: number;
|
|
671
|
+
statusText?: string;
|
|
672
|
+
headers?: Record<string, string>;
|
|
673
|
+
timestamp: number;
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Retry attempt event
|
|
678
|
+
*/
|
|
679
|
+
export interface RetryAttemptEvent extends BaseEvent {
|
|
680
|
+
type: 'retry:attempt';
|
|
681
|
+
data: {
|
|
682
|
+
error: {
|
|
683
|
+
message: string;
|
|
684
|
+
code?: string;
|
|
685
|
+
status?: number;
|
|
686
|
+
};
|
|
687
|
+
attempt: number;
|
|
688
|
+
maxAttempts: number;
|
|
689
|
+
delay: number;
|
|
690
|
+
url?: string;
|
|
691
|
+
method?: string;
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Union type for all client event types
|
|
696
|
+
*/
|
|
697
|
+
export type ClientEventType = ClientConflictEvent | ClientDebugEvent | ClientCreatedEvent | RequestStartEvent | ResponseReceivedEvent | RetryAttemptEvent;
|
|
628
698
|
export type AnyHeaderEvent = HeaderEventData;
|
|
629
699
|
export type AnyNetworkEvent = NetworkEventData;
|
|
630
700
|
export type AnyErrorEvent = ErrorEventData;
|
|
@@ -632,10 +702,11 @@ export type AnyDebugEvent = DebugEventData;
|
|
|
632
702
|
export type AnyPerformanceEvent = PerformanceEventData;
|
|
633
703
|
export type AnyConfigEvent = ConfigEventData;
|
|
634
704
|
export type AnyCacheEvent = CacheEventData;
|
|
705
|
+
export type AnyClientEvent = ClientEventType;
|
|
635
706
|
/**
|
|
636
707
|
* Combined event type
|
|
637
708
|
*/
|
|
638
|
-
export type AnyEvent = AnyHeaderEvent | AnyNetworkEvent | AnyErrorEvent | AnyDebugEvent | AnyPerformanceEvent | AnyConfigEvent | AnyCacheEvent;
|
|
709
|
+
export type AnyEvent = AnyHeaderEvent | AnyNetworkEvent | AnyErrorEvent | AnyDebugEvent | AnyPerformanceEvent | AnyConfigEvent | AnyCacheEvent | AnyClientEvent;
|
|
639
710
|
export type HeaderEventHandler = EventHandler<HeaderEventData>;
|
|
640
711
|
export type NetworkEventHandler = EventHandler<NetworkEventData>;
|
|
641
712
|
export type ErrorEventHandler = EventHandler<ErrorEventData>;
|
|
@@ -650,6 +721,7 @@ export type AnyDebugEventHandler = EventHandler<AnyDebugEvent>;
|
|
|
650
721
|
export type AnyPerformanceEventHandler = EventHandler<AnyPerformanceEvent>;
|
|
651
722
|
export type AnyConfigEventHandler = EventHandler<AnyConfigEvent>;
|
|
652
723
|
export type AnyCacheEventHandler = EventHandler<AnyCacheEvent>;
|
|
724
|
+
export type AnyClientEventHandler = EventHandler<AnyClientEvent>;
|
|
653
725
|
export type UniversalEventHandler = EventHandler<AnyEvent>;
|
|
654
726
|
/**
|
|
655
727
|
* Header event handlers interface
|
|
@@ -713,11 +785,11 @@ export interface CacheEventHandlers {
|
|
|
713
785
|
* Client event handlers interface
|
|
714
786
|
*/
|
|
715
787
|
export interface ClientEventHandlers {
|
|
716
|
-
onClientConflict?: (event:
|
|
717
|
-
onClientDebug?: (event:
|
|
718
|
-
onClientCreated?: (event:
|
|
719
|
-
onRequestStart?: (event:
|
|
720
|
-
onResponseReceived?: (event:
|
|
721
|
-
onRetryAttempt?: (event:
|
|
722
|
-
onAnyClientEvent?: (event:
|
|
788
|
+
onClientConflict?: (event: ClientConflictEvent) => void;
|
|
789
|
+
onClientDebug?: (event: ClientDebugEvent) => void;
|
|
790
|
+
onClientCreated?: (event: ClientCreatedEvent) => void;
|
|
791
|
+
onRequestStart?: (event: RequestStartEvent) => void;
|
|
792
|
+
onResponseReceived?: (event: ResponseReceivedEvent) => void;
|
|
793
|
+
onRetryAttempt?: (event: RetryAttemptEvent) => void;
|
|
794
|
+
onAnyClientEvent?: (event: ClientEventType) => void;
|
|
723
795
|
}
|
package/package.json
CHANGED