- Added cache strategies: NetworkFirst, CacheFirst, StaleWhileRevalidate, NetworkOnly, and CacheOnly. - Introduced InterceptorManager for managing request, response, and error interceptors. - Developed RetryManager for handling request retries with customizable backoff strategies. - Implemented RequestDeduplicator to prevent simultaneous identical requests. - Created timeout utilities for handling request timeouts. - Enhanced WebrequestClient to support global interceptors, caching, and retry logic. - Added convenience methods for common HTTP methods (GET, POST, PUT, DELETE) with JSON handling. - Established a fetch-compatible webrequest function for seamless integration. - Defined core type structures for caching, retry options, interceptors, and web request configurations.
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
/**
|
|
* @push.rocks/webrequest v4
|
|
* Modern, fetch-compatible web request library with intelligent caching
|
|
*/
|
|
|
|
// Main exports
|
|
export { webrequest } from './webrequest.function.js';
|
|
export { WebrequestClient } from './webrequest.client.js';
|
|
|
|
// Type exports
|
|
export type {
|
|
IWebrequestOptions,
|
|
ICacheOptions,
|
|
IRetryOptions,
|
|
IInterceptors,
|
|
TCacheStrategy,
|
|
TStandardCacheMode,
|
|
TBackoffStrategy,
|
|
TWebrequestResult,
|
|
IWebrequestSuccess,
|
|
IWebrequestError,
|
|
ICacheEntry,
|
|
ICacheMetadata,
|
|
} from './webrequest.types.js';
|
|
|
|
export type {
|
|
TRequestInterceptor,
|
|
TResponseInterceptor,
|
|
TErrorInterceptor,
|
|
} from './interceptors/interceptor.types.js';
|
|
|
|
// Advanced exports for custom implementations
|
|
export { CacheManager } from './cache/cache.manager.js';
|
|
export { CacheStore } from './cache/cache.store.js';
|
|
export { RetryManager } from './retry/retry.manager.js';
|
|
export { InterceptorManager } from './interceptors/interceptor.manager.js';
|
|
export { RequestDeduplicator } from './utils/deduplicator.js';
|
|
|
|
// Cache utilities
|
|
export {
|
|
extractCacheMetadata,
|
|
isFresh,
|
|
requiresRevalidation,
|
|
createConditionalHeaders,
|
|
headersToObject,
|
|
objectToHeaders,
|
|
} from './cache/cache.headers.js';
|