@swell/apps-sdk 1.0.139 → 1.0.140
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 +74 -48
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +74 -48
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +74 -48
- package/dist/index.mjs.map +3 -3
- package/dist/src/cache/cache.d.ts +10 -5
- package/dist/src/cache/cf-worker-kv-keyv-adapter.d.ts +8 -5
- package/dist/src/cache/index.d.ts +4 -5
- package/dist/src/cache/request-cache.d.ts +1 -2
- package/dist/src/theme.d.ts +1 -1
- package/dist/types/swell.d.ts +3 -3
- package/package.json +3 -3
|
@@ -4,7 +4,6 @@ export type CreateCacheOptions = OriginalCreateCacheOptions & {
|
|
|
4
4
|
kvStore?: CFWorkerKV;
|
|
5
5
|
workerCtx?: CFWorkerContext;
|
|
6
6
|
};
|
|
7
|
-
export declare const CF_KV_NAMESPACE = "THEME";
|
|
8
7
|
/**
|
|
9
8
|
* Cache supports memory or KV
|
|
10
9
|
* The KV layer supports namespacing and compression
|
|
@@ -13,15 +12,21 @@ export declare class Cache {
|
|
|
13
12
|
private client;
|
|
14
13
|
private workerCtx?;
|
|
15
14
|
constructor(options?: CreateCacheOptions);
|
|
16
|
-
fetch<T>(key: string, fetchFn: () => T | Promise<T
|
|
15
|
+
fetch<T>(key: string, fetchFn: () => T | Promise<T>, ttl?: number): Promise<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Fetch cache using SWR (stale-while-revalidate)
|
|
18
|
+
*
|
|
19
|
+
* This will always return the cached value immediately if exists
|
|
20
|
+
*/
|
|
17
21
|
fetchSWR<T>(key: string, fetchFn: () => T | Promise<T>, ttl?: number): Promise<T>;
|
|
18
|
-
get<T>(key: string): Promise<T |
|
|
22
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
19
23
|
set<T>(key: string, value: T, ttl?: number): Promise<T>;
|
|
20
24
|
flush(key: string): Promise<void>;
|
|
21
25
|
/**
|
|
22
26
|
* Flushes the entire cache.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
27
|
+
*
|
|
28
|
+
* __WARNING__: If the cache store is shared among many cache clients,
|
|
29
|
+
* this will flush entries for other clients.
|
|
25
30
|
*/
|
|
26
31
|
flushAll(): Promise<void>;
|
|
27
32
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import type { KeyvStoreAdapter } from 'keyv';
|
|
1
2
|
import type { CFWorkerKV } from 'types/swell';
|
|
2
3
|
/**
|
|
3
4
|
* CloudFlare Workers KV adapter for Keyv.
|
|
4
5
|
* Includes namespacing to prevent conflicts within shared storage.
|
|
5
6
|
*/
|
|
6
|
-
export declare class CFWorkerKVKeyvAdapter {
|
|
7
|
-
private namespace;
|
|
7
|
+
export declare class CFWorkerKVKeyvAdapter implements KeyvStoreAdapter {
|
|
8
8
|
private store;
|
|
9
|
+
namespace: string;
|
|
10
|
+
opts: unknown;
|
|
9
11
|
constructor(store: CFWorkerKV);
|
|
10
12
|
has(key: string): Promise<boolean>;
|
|
11
|
-
get(key: string): Promise<
|
|
12
|
-
set(key: string, value:
|
|
13
|
-
delete(key: string): Promise<
|
|
13
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
14
|
+
set(key: string, value: string, ttl?: number): Promise<void>;
|
|
15
|
+
delete(key: string): Promise<boolean>;
|
|
14
16
|
clear(): Promise<void>;
|
|
17
|
+
on(_event: string, _listener: (...args: unknown[]) => void): CFWorkerKVKeyvAdapter;
|
|
15
18
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { Cache, RequestCache, ResourceCache, ThemeCache };
|
|
1
|
+
export { Cache } from './cache';
|
|
2
|
+
export { RequestCache } from './request-cache';
|
|
3
|
+
export { ResourceCache } from './resource-cache';
|
|
4
|
+
export { ThemeCache } from './theme-cache';
|
package/dist/src/theme.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare class SwellTheme {
|
|
|
46
46
|
account: SwellStorefrontSingleton | null;
|
|
47
47
|
customer?: SwellStorefrontSingleton | null;
|
|
48
48
|
}>;
|
|
49
|
-
fetchSingletonResourceCached<R>(key: string, handler: () => Promise<R>, defaultValue: R): Promise<R | undefined>;
|
|
49
|
+
fetchSingletonResourceCached<R>(key: string, handler: () => Promise<R>, defaultValue: () => R | Promise<R>): Promise<R | undefined>;
|
|
50
50
|
fetchCart(): Promise<StorefrontResource>;
|
|
51
51
|
fetchAccount(): Promise<StorefrontResource | null>;
|
|
52
52
|
getFormConfig(formType: string): ThemeFormConfig | undefined;
|
package/dist/types/swell.d.ts
CHANGED
|
@@ -565,11 +565,11 @@ export interface CFWorkerKVListResponse {
|
|
|
565
565
|
export interface CFWorkerKV {
|
|
566
566
|
get(key: string, type?: 'text', options?: CFWorkerKVGetOptions<'text'>): Promise<string | null>;
|
|
567
567
|
get(key: string, type?: 'arrayBuffer', options?: CFWorkerKVGetOptions<'arrayBuffer'>): Promise<ArrayBuffer | null>;
|
|
568
|
-
get(key: string, type?: 'stream', options?: CFWorkerKVGetOptions<'stream'>): Promise<ReadableStream | null>;
|
|
568
|
+
get(key: string, type?: 'stream', options?: CFWorkerKVGetOptions<'stream'>): Promise<ReadableStream<Uint8Array> | null>;
|
|
569
569
|
get<T>(key: string, type?: 'json', options?: CFWorkerKVGetOptions<'json'>): Promise<T | null>;
|
|
570
570
|
getWithMetadata(key: string, type?: 'text', options?: CFWorkerKVGetOptions<'text'>): Promise<CFWorkerKVGetMetadataResponse<string>>;
|
|
571
571
|
getWithMetadata(key: string, type?: 'arrayBuffer', options?: CFWorkerKVGetOptions<'arrayBuffer'>): Promise<CFWorkerKVGetMetadataResponse<ArrayBuffer>>;
|
|
572
|
-
getWithMetadata(key: string, type?: 'stream', options?: CFWorkerKVGetOptions<'stream'>): Promise<CFWorkerKVGetMetadataResponse<ReadableStream
|
|
572
|
+
getWithMetadata(key: string, type?: 'stream', options?: CFWorkerKVGetOptions<'stream'>): Promise<CFWorkerKVGetMetadataResponse<ReadableStream<Uint8Array>>>;
|
|
573
573
|
getWithMetadata<T>(key: string, type?: 'json', options?: CFWorkerKVGetOptions<'json'>): Promise<CFWorkerKVGetMetadataResponse<T>>;
|
|
574
574
|
put(key: string, value: string | ReadableStream | ArrayBuffer, options?: CFWorkerKVPutOptions): Promise<void>;
|
|
575
575
|
delete(key: string): Promise<void>;
|
|
@@ -579,7 +579,7 @@ export interface CFThemeEnv {
|
|
|
579
579
|
THEME?: CFWorkerKV;
|
|
580
580
|
}
|
|
581
581
|
export interface CFWorkerContext {
|
|
582
|
-
waitUntil(promise: Promise<
|
|
582
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
583
583
|
passThroughOnException(): void;
|
|
584
584
|
}
|
|
585
585
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swell/apps-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.140",
|
|
5
5
|
"description": "Swell SDK for building isomorphic apps.",
|
|
6
6
|
"author": "Swell",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@swell/easyblocks-core": "^1.0.19",
|
|
42
42
|
"bluebird": "^3.7.2",
|
|
43
|
-
"cache-manager": "^
|
|
43
|
+
"cache-manager": "^7.0.1",
|
|
44
44
|
"color": "^4.2.3",
|
|
45
45
|
"country-flag-icons": "1.5.18",
|
|
46
46
|
"json5": "^2.2.3",
|
|
47
|
-
"keyv": "^5.
|
|
47
|
+
"keyv": "^5.3.4",
|
|
48
48
|
"liquidjs": "^10.21.0",
|
|
49
49
|
"lodash": "^4.17.21",
|
|
50
50
|
"lodash-es": "^4.17.21",
|