create-request 0.0.1-beta.9 → 1.0.0
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 +534 -303
- package/dist/library/BaseRequest.d.ts +274 -41
- package/dist/library/BodyRequest.d.ts +27 -4
- package/dist/library/RequestError.d.ts +5 -2
- package/dist/library/ResponseWrapper.d.ts +66 -13
- package/dist/library/enums.d.ts +0 -11
- package/dist/library/index.cjs +2109 -0
- package/dist/library/index.cjs.map +1 -0
- package/dist/library/index.d.ts +12 -12
- package/dist/library/index.esm.js +1321 -725
- package/dist/library/index.esm.js.map +1 -0
- package/dist/library/index.esm.min.js +1 -0
- package/dist/library/index.esm.min.js.map +1 -0
- package/dist/library/index.min.cjs +1 -0
- package/dist/library/index.min.cjs.map +1 -0
- package/dist/library/requestFactories.d.ts +70 -9
- package/dist/library/requestMethods.d.ts +70 -3
- package/dist/library/types.d.ts +44 -5
- package/dist/library/utils/Config.d.ts +164 -12
- package/dist/library/utils/CookieUtils.d.ts +1 -1
- package/dist/library/utils/sizeUtils.d.ts +8 -0
- package/package.json +74 -16
- package/dist/library/index.js +0 -1525
- package/dist/library/types/cache.d.ts +0 -62
- package/dist/library/utils/CacheManager.d.ts +0 -35
- package/dist/library/utils/CacheStorage.d.ts +0 -57
- package/dist/library/utils/StorageProvider.d.ts +0 -33
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { StorageProvider } from "../utils/StorageProvider";
|
|
2
|
-
/**
|
|
3
|
-
* Cache entry with metadata
|
|
4
|
-
*/
|
|
5
|
-
export interface CacheEntry {
|
|
6
|
-
value: any;
|
|
7
|
-
expiry: number | null;
|
|
8
|
-
timestamp: number;
|
|
9
|
-
headers?: Record<string, string>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Options for cache configuration
|
|
13
|
-
*/
|
|
14
|
-
export interface CacheOptions {
|
|
15
|
-
/**
|
|
16
|
-
* Storage provider to use for caching
|
|
17
|
-
* Default is memory cache (new Map())
|
|
18
|
-
*/
|
|
19
|
-
storage?: StorageProvider | Storage | Map<string, any>;
|
|
20
|
-
/**
|
|
21
|
-
* Time to live in milliseconds
|
|
22
|
-
* Default is no expiration
|
|
23
|
-
*/
|
|
24
|
-
ttl?: number;
|
|
25
|
-
/**
|
|
26
|
-
* Custom key generator function
|
|
27
|
-
* @param url Request URL
|
|
28
|
-
* @param method Request method
|
|
29
|
-
* @param headers Request headers
|
|
30
|
-
* @param body Request body
|
|
31
|
-
*/
|
|
32
|
-
keyGenerator?: (url: string, method: string, headers?: Record<string, string>, body?: any) => string;
|
|
33
|
-
/**
|
|
34
|
-
* Headers to vary the cache by
|
|
35
|
-
* If these headers change, a new cache entry will be created
|
|
36
|
-
*/
|
|
37
|
-
varyByHeaders?: string[];
|
|
38
|
-
/**
|
|
39
|
-
* Maximum number of entries in the cache
|
|
40
|
-
* Only applicable for memory cache (Map)
|
|
41
|
-
*/
|
|
42
|
-
maxEntries?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Maximum size of the cache in bytes or with units (e.g. "10MB")
|
|
45
|
-
* String format supports KB, MB, GB (case-insensitive)
|
|
46
|
-
*/
|
|
47
|
-
maxSize?: number | string;
|
|
48
|
-
/**
|
|
49
|
-
* Prefix for cache keys
|
|
50
|
-
* Useful for namespacing cache entries
|
|
51
|
-
*/
|
|
52
|
-
keyPrefix?: string;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Type for cacheable response data
|
|
56
|
-
*/
|
|
57
|
-
export type CacheableResponse = {
|
|
58
|
-
data: any;
|
|
59
|
-
headers: Record<string, string>;
|
|
60
|
-
status: number;
|
|
61
|
-
statusText: string;
|
|
62
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { CacheEntry, CacheOptions } from "../types/cache";
|
|
2
|
-
/**
|
|
3
|
-
* Cache manager that handles storage operations
|
|
4
|
-
*/
|
|
5
|
-
export declare class CacheManager {
|
|
6
|
-
private storage;
|
|
7
|
-
private options;
|
|
8
|
-
private entryCount;
|
|
9
|
-
private totalSize;
|
|
10
|
-
constructor(options?: CacheOptions);
|
|
11
|
-
/**
|
|
12
|
-
* Generate a cache key based on request details
|
|
13
|
-
*/
|
|
14
|
-
generateKey(url: string, method: string, headers?: Record<string, string>, body?: unknown): string;
|
|
15
|
-
/**
|
|
16
|
-
* Get a value from cache
|
|
17
|
-
*/
|
|
18
|
-
get(key: string): Promise<CacheEntry | null>;
|
|
19
|
-
/**
|
|
20
|
-
* Set a value in cache
|
|
21
|
-
*/
|
|
22
|
-
set(key: string, value: unknown, headers?: Record<string, string>): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Check if a key exists in the cache
|
|
25
|
-
*/
|
|
26
|
-
has(key: string): Promise<boolean>;
|
|
27
|
-
/**
|
|
28
|
-
* Delete a key from the cache
|
|
29
|
-
*/
|
|
30
|
-
delete(key: string): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Clear the entire cache
|
|
33
|
-
*/
|
|
34
|
-
clear(): Promise<void>;
|
|
35
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { CacheEntry, CacheOptions } from "../types/cache";
|
|
2
|
-
import type { StorageProvider } from "./StorageProvider";
|
|
3
|
-
/**
|
|
4
|
-
* Parse size strings like "10MB" into bytes
|
|
5
|
-
* @param size Size as number or string with units
|
|
6
|
-
*/
|
|
7
|
-
export declare function parseSize(size: string | number): number;
|
|
8
|
-
/**
|
|
9
|
-
* Create a memory storage provider using Map
|
|
10
|
-
*/
|
|
11
|
-
export declare function createMemoryStorage(): StorageProvider;
|
|
12
|
-
/**
|
|
13
|
-
* Create a localStorage-based storage provider
|
|
14
|
-
*/
|
|
15
|
-
export declare function createLocalStorageStorage(): StorageProvider;
|
|
16
|
-
/**
|
|
17
|
-
* Create a sessionStorage-based storage provider
|
|
18
|
-
*/
|
|
19
|
-
export declare function createSessionStorageStorage(): StorageProvider;
|
|
20
|
-
/**
|
|
21
|
-
* Create a storage provider from a cache options object
|
|
22
|
-
*/
|
|
23
|
-
export declare function createStorageProvider(options?: CacheOptions): StorageProvider;
|
|
24
|
-
/**
|
|
25
|
-
* Cache manager that handles storage operations
|
|
26
|
-
*/
|
|
27
|
-
export declare class CacheManager {
|
|
28
|
-
private storage;
|
|
29
|
-
private options;
|
|
30
|
-
private entryCount;
|
|
31
|
-
private totalSize;
|
|
32
|
-
constructor(options?: CacheOptions);
|
|
33
|
-
/**
|
|
34
|
-
* Generate a cache key based on request details
|
|
35
|
-
*/
|
|
36
|
-
generateKey(url: string, method: string, headers?: Record<string, string>, body?: any): string;
|
|
37
|
-
/**
|
|
38
|
-
* Get a value from cache
|
|
39
|
-
*/
|
|
40
|
-
get(key: string): Promise<CacheEntry | null>;
|
|
41
|
-
/**
|
|
42
|
-
* Set a value in cache
|
|
43
|
-
*/
|
|
44
|
-
set(key: string, value: unknown, headers?: Record<string, string>): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Check if a key exists in the cache
|
|
47
|
-
*/
|
|
48
|
-
has(key: string): Promise<boolean>;
|
|
49
|
-
/**
|
|
50
|
-
* Delete a key from the cache
|
|
51
|
-
*/
|
|
52
|
-
delete(key: string): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Clear the entire cache
|
|
55
|
-
*/
|
|
56
|
-
clear(): Promise<void>;
|
|
57
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface for storage providers used by the cache system
|
|
3
|
-
*/
|
|
4
|
-
export interface StorageProvider {
|
|
5
|
-
/**
|
|
6
|
-
* Get a value from storage
|
|
7
|
-
* @param key The key to retrieve
|
|
8
|
-
* @returns The stored value or null if not found
|
|
9
|
-
*/
|
|
10
|
-
get(key: string): Promise<string | null> | string | null;
|
|
11
|
-
/**
|
|
12
|
-
* Set a value in storage
|
|
13
|
-
* @param key The key to store
|
|
14
|
-
* @param value The value to store
|
|
15
|
-
* @param ttl Optional TTL in milliseconds
|
|
16
|
-
* @returns Promise or void
|
|
17
|
-
*/
|
|
18
|
-
set(key: string, value: string, ttl?: number): Promise<void> | void;
|
|
19
|
-
/**
|
|
20
|
-
* Check if a key exists in storage
|
|
21
|
-
* @param key The key to check
|
|
22
|
-
*/
|
|
23
|
-
has(key: string): Promise<boolean> | boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Delete a value from storage
|
|
26
|
-
* @param key The key to delete
|
|
27
|
-
*/
|
|
28
|
-
delete(key: string): Promise<void> | void;
|
|
29
|
-
/**
|
|
30
|
-
* Clear all values from storage
|
|
31
|
-
*/
|
|
32
|
-
clear(): Promise<void> | void;
|
|
33
|
-
}
|