@swell/apps-sdk 1.0.162 → 1.0.163
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/dist/index.cjs +65 -27
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +65 -27
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +65 -27
- package/dist/index.mjs.map +3 -3
- package/dist/src/api.d.ts +4 -0
- package/dist/src/cache/cache.d.ts +10 -1
- package/package.json +1 -1
package/dist/src/api.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ export declare class Swell {
|
|
|
28
28
|
swellHeaders: Record<string, string | undefined>;
|
|
29
29
|
};
|
|
30
30
|
static formatQueryParams(queryParams?: URLSearchParams | Record<string, string | undefined>): qs.ParsedQs;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if cache bypass is requested via X-Cache-Bypass header
|
|
33
|
+
*/
|
|
34
|
+
private shouldBypassCache;
|
|
31
35
|
/**
|
|
32
36
|
* Fetches a resource.
|
|
33
37
|
* First attempts to fetch from cache.
|
|
@@ -12,7 +12,16 @@ export declare class Cache {
|
|
|
12
12
|
private client;
|
|
13
13
|
private workerCtx?;
|
|
14
14
|
constructor(options?: CreateCacheOptions);
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Always fetches fresh data and updates cache
|
|
17
|
+
* Deduplicates concurrent requests with the same key
|
|
18
|
+
*
|
|
19
|
+
* @param key Cache key
|
|
20
|
+
* @param fetchFn Function to fetch fresh data
|
|
21
|
+
* @param ttl Time to live in milliseconds (default: DEFAULT_SWR_TTL)
|
|
22
|
+
* @param isCacheable Whether to store result in cache (default: true)
|
|
23
|
+
*/
|
|
24
|
+
fetch<T>(key: string, fetchFn: () => T | Promise<T>, ttl?: number, isCacheable?: boolean): Promise<T>;
|
|
16
25
|
/**
|
|
17
26
|
* Fetch cache using SWR (stale-while-revalidate)
|
|
18
27
|
*
|